Module: Amorail::MethodMissing

Included in:
Property::PropertyItem
Defined in:
lib/amorail/property.rb

Overview

Return hash key as method call

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/amorail/property.rb', line 6

def method_missing(method_sym, *arguments, &block)
  if data.key?(method_sym.to_s.downcase)
    data.fetch(method_sym.to_s.downcase)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method_sym, *args) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/amorail/property.rb', line 14

def respond_to_missing?(method_sym, *args)
  args.size.zero? && data.key?(method_sym.to_s.downcase)
end