Module: OptionsHash::MethodObject::InstanceMethods

Defined in:
lib/options_hash/method_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Raises:

  • (NoMethodError)


42
43
44
45
# File 'lib/options_hash/method_object.rb', line 42

def method_missing method, *args, &block
  return options[method] if options.keys.include?(method)
  raise NoMethodError, "undefined method `#{method}'", caller(1)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



40
41
42
# File 'lib/options_hash/method_object.rb', line 40

def options
  @options
end

Instance Method Details

#given?(key) ⇒ Boolean



47
48
49
# File 'lib/options_hash/method_object.rb', line 47

def given? key
  options.given? key
end

#initialize(options = {}) ⇒ Object



37
38
39
# File 'lib/options_hash/method_object.rb', line 37

def initialize options={}
  @options = self.class.options.parse(options)
end