Class: Calibrate::Configurable::ProxyDecorator
- Inherits:
-
Object
- Object
- Calibrate::Configurable::ProxyDecorator
- Defined in:
- lib/calibrate/configurable/proxy-value.rb
Instance Method Summary collapse
-
#initialize(configurable) ⇒ ProxyDecorator
constructor
A new instance of ProxyDecorator.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(configurable) ⇒ ProxyDecorator
Returns a new instance of ProxyDecorator.
15 16 17 |
# File 'lib/calibrate/configurable/proxy-value.rb', line 15 def initialize(configurable) @configurable = configurable end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/calibrate/configurable/proxy-value.rb', line 19 def method_missing(name, *args, &block) unless block.nil? and args.empty? raise NoMethodError, "method `#{name}' not defined with arguments or block when proxied" end unless @configurable.respond_to?(name) raise NoMethodError, "cannot proxy `#{name}' - undefined on #{@configurable}" end return ProxyValue.new(@configurable, @configurable.class.(name)) end |