Class: ActionController::Base::PlayResourceObject
- Inherits:
- BasicObject
- Defined in:
- lib/can_play/controller.rb
Overview
对current_power采用动态方法调用的装饰者。
Instance Method Summary collapse
-
#initialize(obj, klass) ⇒ PlayResourceObject
constructor
A new instance of PlayResourceObject.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(obj, klass) ⇒ PlayResourceObject
Returns a new instance of PlayResourceObject.
21 22 23 24 |
# File 'lib/can_play/controller.rb', line 21 def initialize(obj, klass) @obj = obj @klass = klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/can_play/controller.rb', line 26 def method_missing(method, *args, &block) if @obj.respond_to? "#{method}_evaluate_in_#{@klass.override_code}_scope" @obj.send("#{method}_evaluate_in_#{@klass.override_code}_scope", *args, &block) elsif @obj.respond_to? method @obj.send(method, *args, &block) else super end end |