Class: OpenHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/ohash.rb

Overview

Since I personally hate OpenStructs, this is a Hash with the same features, but it’s mergeable etc…

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/ohash.rb', line 8

def method_missing meth, *args
    method = meth.to_s

    if method =~ %r{.+=$}
        super unless args.length == 1
        self[method[0...-1].to_sym] = args.first
    else
        self[meth]
    end
end