Class: Caesar::Hash

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

Overview

A subclass of ::Hash that provides method names for hash parameters. It’s like a lightweight OpenStruct.

ch = Caesar::Hash[:tabasco => :lots!]
puts ch.tabasco  # => lots!

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



19
20
21
# File 'lib/caesar.rb', line 19

def method_missing(meth)
  (self.has_key?(meth)) ? self[meth] : nil
end