Module: MethodifyHash::Module

Defined in:
lib/methodify_hash/module.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id) ⇒ Object



5
6
7
8
# File 'lib/methodify_hash/module.rb', line 5

def method_missing(method_id)
  attr_name = method_id.id2name
  self[attr_name] || self[attr_name.to_sym]
end

Class Method Details

.extended(klass) ⇒ Object



10
11
12
13
14
# File 'lib/methodify_hash/module.rb', line 10

def self.extended(klass)
  if (klass == Hash) == false && (klass.class == Hash) == false
    raise NoHashError, 'MethodifyHash was not used on a Hash'
  end
end

.included(klass) ⇒ Object



16
17
18
19
20
# File 'lib/methodify_hash/module.rb', line 16

def self.included(klass)
  if (klass == Hash) == false && (klass.class == Hash) == false
    raise NoHashError, 'MethodifyHash was not used on a Hash'
  end
end