Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/comatose/templates/comatose.rb

Direct Known Subclasses

Comatose::ProcessingContext

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *arg) ⇒ Object

Having the method_missing catchall in conjunction with get_binding allows us to use the hash as a Context for ERB



20
21
22
23
24
25
26
# File 'lib/generators/comatose/templates/comatose.rb', line 20

def method_missing(meth, *arg)
  if self.has_key? meth.to_s
    self[meth.to_s]
  else
    super
  end
end

Instance Method Details

#get_bindingObject

Gets the binding object for use with ERB



30
31
32
# File 'lib/generators/comatose/templates/comatose.rb', line 30

def get_binding
  binding
end