Module: Sourced::Decide::ClassMethods
- Defined in:
- lib/sourced/decide.rb
Instance Method Summary collapse
- #decide(cmd_type, &block) ⇒ Object
- #handle_command(_command) ⇒ Object
- #handled_commands ⇒ Object
- #inherited(subclass) ⇒ Object
Instance Method Details
#decide(cmd_type, &block) ⇒ Object
44 45 46 47 |
# File 'lib/sourced/decide.rb', line 44 def decide(cmd_type, &block) handled_commands << cmd_type define_method(Sourced.(PREFIX, cmd_type.name), &block) end |
#handle_command(_command) ⇒ Object
36 37 38 |
# File 'lib/sourced/decide.rb', line 36 def handle_command(_command) raise NoMethodError, "implement .handle_command(Command) in #{self}" end |
#handled_commands ⇒ Object
40 41 42 |
# File 'lib/sourced/decide.rb', line 40 def handled_commands @handled_commands ||= [] end |
#inherited(subclass) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/sourced/decide.rb', line 29 def inherited(subclass) super handled_commands.each do |cmd_type| subclass.handled_commands << cmd_type end end |