Class: IndifferentHash

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

Overview

Copyright 2007, LAIKA, Inc. #

#

Authors: #

* Ben Bleything <bbleything@laika.com>                    #

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/indifferent_hash.rb', line 11

def []( key )
  candidate = self.fetch( key ) rescue false
  return candidate if candidate

  [ :to_s, :intern ].each do |modifier|
    candidate = self.fetch( key.send(modifier) ) if key.respond_to? modifier rescue false
    return candidate if candidate
  end

  return nil
end