module Lab42::NHash::Interpolation

Public Instance Methods

current_binding() click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 31
def current_binding
  @binding_stack.last || ( root? ? binding : parent.current_binding )
end
fetch!(*args, &blk)
Alias for: get!
get!(*args, &blk) click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 6
def get! *args, &blk
  result = get( *args, &blk )
  _expand_result result
end
Also aliased as: fetch!
get_with_binding(key, a_binding, *rst, &blk) click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 12
def get_with_binding key, a_binding, *rst, &blk
  with_binding a_binding do
    get!( key, *rst, &blk )
  end
end
get_with_current(&blk) click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 18
def get_with_current &blk
  with_binding blk.binding do
    get! blk.()
  end
end
root?() click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 35
def root?
  parent == self || parent.nil?
end
with_binding(a_binding, &blk) click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 24
def with_binding a_binding, &blk
  push_binding a_binding
  _invoke blk, self
ensure
  pop_binding
end

Private Instance Methods

_expand_result(value) click to toggle source
# File lib/lab42/nhash/interpolation.rb, line 39
def _expand_result value
  ERB.new( value ).result( current_binding )
end