Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/omdbapi/default.rb

Overview

Reopen the Hash class to add method.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

Allow accessing hashes via dot notation.

Parameters:

  • name (String)

    The method name.

Returns:

  • (Object)


19
20
21
22
23
# File 'lib/omdbapi/default.rb', line 19

def method_missing(name)
  return self[name] if key? name
  self.each { |k,v| return v if k.to_s.to_sym == name }
  super.method_missing name
end