Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_ninja/active_hash.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/hash_ninja/active_hash.rb', line 111

def method_missing(name, *args, &block)
  # for ActiveHash#recursively_xxx
  if name.match(/recursively_/)
    method_name = name.to_s.sub(/^recursively_/, '')
    self.each do |value|
      if value.is_a? Hash
        value.extend HashNinja::ActiveHash
        value.public_send(name, *args, &block)
      elsif value.is_a? Array
        value.public_send(name, *args, &block)
      end
    end
    self
  end
end