Class: Woyo::Action
- Inherits:
-
WorldObject
- Object
- WorldObject
- Woyo::Action
- Defined in:
- lib/woyo/world/action.rb
Instance Attribute Summary
Attributes inherited from WorldObject
Instance Method Summary collapse
- #execute ⇒ Object
- #execution(&block) ⇒ Object
- #initialize_object ⇒ Object
- #location_or_context ⇒ Object
Methods inherited from WorldObject
#attribute_changes, #attribute_clear_changes, #changes, #clear_changes, #initialize, #uid
Methods included from Evaluate
#children, #evaluate, included
Methods included from Attributes
#attribute, #attributes, #changes, #clear_changes, #define_attr, #define_attr!, #define_attr?, #define_attr_default, #define_attr_equals, #define_attr_methods, #dependent_changes, #exclusion, #exclusions, #group, #groups, #is, #is?, #track_changes
Constructor Details
This class inherits a constructor from Woyo::WorldObject
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/woyo/world/action.rb', line 14 def execute location_or_context.clear_changes result = if @proc.arity < 1 @context.instance_eval &@proc else @context.instance_exec self, &@proc end unless result.kind_of? Hash result = { return: result } end # result: { location: :place } signals change of location (like going a way!) # todo: fill return hash with action attributes, groups, exclusions ? ... { describe: describe, result: result, changes: location_or_context.changes } end |
#execution(&block) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/woyo/world/action.rb', line 29 def execution &block if block_given? @proc = block else @proc end end |
#initialize_object ⇒ Object
8 9 10 11 12 |
# File 'lib/woyo/world/action.rb', line 8 def initialize_object super attribute :describe @proc = proc { nil } end |