Class: Ektoplayer::Operations::Operations
- Inherits:
-
Object
- Object
- Ektoplayer::Operations::Operations
- Defined in:
- lib/ektoplayer/operations/operations.rb
Overview
Operations Since every operation is implemented excactly once we don’t use an Event object.
Since doing a “class.send()” is faster than “hash.call()” we implement the operations using an object instead of a hash.
Instance Method Summary collapse
-
#register(name, &block) ⇒ Object
(also: #reg)
Register a new command.
-
#with_register(prefix = '', &block) ⇒ Object
Helper for registering multiple commands.
Instance Method Details
#register(name, &block) ⇒ Object Also known as: reg
Register a new command
12 13 14 |
# File 'lib/ektoplayer/operations/operations.rb', line 12 def register(name, &block) self.define_singleton_method(name, &block) end |
#with_register(prefix = '', &block) ⇒ Object
Helper for registering multiple commands
18 19 20 21 22 |
# File 'lib/ektoplayer/operations/operations.rb', line 18 def with_register(prefix='', &block) reg_func = proc { |name, &blk| register("#{prefix}#{name}", &blk) } block.(reg_func) if block reg_func end |