lib/demiurge/dsl.rb
def on_intention(caught_action, action_to_run, &block)
      @built_item.state["on_action_handlers"] ||= {}
      raise "Already have an on_action (offer) handler for action #{caught_action}! Failing!" if @built_item.state["on_action_handlers"][caught_action]
      @built_item.state["on_action_handlers"][caught_action] = action_to_run
      register_built_action("name" => action_to_run, "block" => block)
      nil
    end
# The specified action will be called for Intentions using the
# appropriate action. This is used to modify or cancel an
# Intention before it runs.
#
# @param caught_action [String] The action type of the Intention being caught, or "all" for all intentions
# @param action_to_run [String] The action name of the new intercepting action
# @yield [Intention] Receives the Intention when these Intentions occur
# @return [void]
# @since 0.0.1
The specified action will be called for Intentions using the
appropriate action. This is used to modify or cancel an
Intention before it runs.
The specified action will be called for Intentions using the appropriate action . This is used to modify or cancel an Intention before it runs .
def on_intention(caught_action, action_to_run, &block)
      @built_item.state["on_action_handlers"] ||= {}
      raise "Already have an on_action (offer) handler for action #{caught_action}! Failing!" if @built_item.state["on_action_handlers"][caught_action]
      @built_item.state["on_action_handlers"][caught_action] = action_to_run
      register_built_action("name" => action_to_run, "block" => block)
      nil
    end
def on_intention ( caught_action , action_to_run , & block ) @built_item . state [ "on_action_handlers" ] ||= { } raise "Already have an on_action (offer) handler for action #{caught_action}! Failing!" if @built_item . state [ "on_action_handlers" ] [ caught_action ] @built_item . state [ "on_action_handlers" ] [ caught_action ] = action_to_run register_built_action ( "name" => action_to_run , "block" => block ) nil end
The specified action will be called for Intentions using the
appropriate action.
The specified action will be called for Intentions using the appropriate action .
None
void
caught_action
The action type of the Intention being caught, or "all" for all intentions
The action type of the Intention being caught or " all " for all intentions
action_to_run
The action name of the new intercepting action
The action name of the new intercepting action
block
]
Receives the Intention when these Intentions occur
Receives the Intention when these Intentions occur
since
None