Class: Calibrate::Configurable::ProxyDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/calibrate/configurable/proxy-value.rb

Instance Method Summary collapse

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