Class: EacRubyUtils::Context

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

Instance Method Summary collapse

Instance Method Details

#currentObject



7
8
9
# File 'lib/eac_ruby_utils/context.rb', line 7

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

#on(obj) ⇒ Object



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

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

#optional_currentObject



11
12
13
# File 'lib/eac_ruby_utils/context.rb', line 11

def optional_current
  stack.last
end