Module: Lab42::NHash::Interpolation

Included in:
Lab42::NHash
Defined in:
lib/lab42/nhash/interpolation.rb

Instance Method Summary collapse

Instance Method Details

#current_bindingObject



31
32
33
# File 'lib/lab42/nhash/interpolation.rb', line 31

def current_binding
  @binding_stack.last || ( root? ? binding : parent.current_binding )
end

#get!(*args, &blk) ⇒ Object Also known as: fetch!



6
7
8
9
# File 'lib/lab42/nhash/interpolation.rb', line 6

def get! *args, &blk
  result = get( *args, &blk )
  _expand_result result
end

#get_with_binding(key, a_binding, *rst, &blk) ⇒ Object



12
13
14
15
16
# 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) ⇒ Object



18
19
20
21
22
# File 'lib/lab42/nhash/interpolation.rb', line 18

def get_with_current &blk
  with_binding blk.binding do
    get! blk.()
  end
end

#root?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/lab42/nhash/interpolation.rb', line 35

def root?
  parent == self || parent.nil?
end

#with_binding(a_binding, &blk) ⇒ Object



24
25
26
27
28
29
# 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