class Woyo::Action
Public Instance Methods
execute()
click to toggle source
# 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)
click to toggle source
# File lib/woyo/world/action.rb, line 29 def execution &block if block_given? @proc = block else @proc end end
initialize_object()
click to toggle source
Calls superclass method
# File lib/woyo/world/action.rb, line 8 def initialize_object super attribute :describe @proc = proc { nil } end
location_or_context()
click to toggle source
# File lib/woyo/world/action.rb, line 37 def location_or_context ancestor = self while ancestor.context do return ancestor if ancestor.kind_of? Woyo::Location ancestor = ancestor.context end ancestor end