lib/azeroth/controller_interface.rb in azeroth-0.8.2 vs lib/azeroth/controller_interface.rb in azeroth-0.9.0

- old
+ new

@@ -40,9 +40,24 @@ # @return [Object] def set(variable, value) controller.instance_variable_set("@#{variable}", value) end + # Forces a controller to run a block + # + # When the block is a +Proc+ that is evaluated, + # when it is a +Symbol+ or +String+, a method is called + # + # @return [Object] whatever the block returns + def run(block) + case block + when Proc + controller.instance_eval(&block) + else + controller.send(block) + end + end + private attr_reader :controller # @method controller # @private