Class: Field::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/field/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, &setup) ⇒ Proxy

Returns a new instance of Proxy.



57
58
59
60
# File 'lib/field/base.rb', line 57

def initialize(options, &setup)
  @options = options
  @setup   = setup
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object



66
67
68
# File 'lib/field/base.rb', line 66

def method_missing(id, *args)
  @options[id] || super
end

Instance Method Details

#factory(name, options = {}) ⇒ Object



62
63
64
# File 'lib/field/base.rb', line 62

def factory(name, options = {})
  @setup.call(name, options, self)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/field/base.rb', line 70

def respond_to_missing?(method_name, include_private = false)
  @options.key? method_name
end