Class: Wongi::Engine::SimpleAction
- Defined in:
- lib/wongi-engine/dsl/actions/simple_action.rb
Instance Attribute Summary
Attributes inherited from Action
#name, #production, #rete, #rule
Instance Method Summary collapse
- #execute(token) ⇒ Object
-
#initialize(action = nil, *args, &block) ⇒ SimpleAction
constructor
A new instance of SimpleAction.
Methods included from CoreExt
Constructor Details
#initialize(action = nil, *args, &block) ⇒ SimpleAction
Returns a new instance of SimpleAction.
5 6 7 8 9 10 11 |
# File 'lib/wongi-engine/dsl/actions/simple_action.rb', line 5 def initialize action = nil, *args, &block @action = if action.is_a? Class action.new *args, &block else action || block end end |
Instance Method Details
#execute(token) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/wongi-engine/dsl/actions/simple_action.rb', line 13 def execute token if @action.is_a?( Proc ) || @action.respond_to?( :to_proc ) rete.instance_exec token, &@action elsif @action.respond_to? :call @action.call token elsif @action.respond_to? :execute @action.execute token end end |