lib/gamefic/action.rb in gamefic-3.0.0 vs lib/gamefic/action.rb in gamefic-3.1.0

- old
+ new

@@ -11,12 +11,14 @@ # Hooks are blocks of code that get executed before or after an actor # performs an action. A before action hook is capable of cancelling the # action's performance. # class Hook + # @param [Array<Symbol>] attr_reader :verbs + # @param [Proc] attr_reader :block def initialize *verbs, &block @verbs = verbs @block = block @@ -43,15 +45,17 @@ @actor = actor @arguments = arguments @response = response end + # @return [self] def execute - return if cancelled? + return self if cancelled? || executed? @executed = true response.execute actor, *arguments + self end # True if the response has been executed. False typically means that the # #execute method has not been called or the action was cancelled in a # before_action hook. @@ -71,9 +75,13 @@ @cancelled ||= false end def verb response.verb + end + + def narrative + response.narrative end def meta? response.meta? end