Class: ERBWithHash::HashAsBinding

Inherits:
BasicObject
Defined in:
lib/erb_with_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashAsBinding

Returns a new instance of HashAsBinding.



5
6
7
# File 'lib/erb_with_hash.rb', line 5

def initialize(hash)
  @_env = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args, &block) ⇒ Object



9
10
11
12
13
# File 'lib/erb_with_hash.rb', line 9

def method_missing(msg, *args, &block)
  super if block
  super unless args.empty?
  @_env.fetch(msg) { @_env.fetch(msg.to_s) { super }}
end