Class: EacRubyUtils::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/context.rb

Instance Method Summary collapse

Instance Method Details

#currentObject



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

def current
  optional_current || raise('No elements in context')
end

#on(obj) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/eac_ruby_utils/context.rb', line 16

def on(obj)
  push(obj)
  begin
    yield
  ensure
    pop
  end
end

#optional_currentObject



9
10
11
# File 'lib/eac_ruby_utils/context.rb', line 9

def optional_current
  stack.last
end