123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Thor::NestedContext

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/vendor/thor/lib/thor/nested_context.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newNestedContext

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/nested_context.rb', line 3

def initialize
  @depth = 0
end

Instance Attribute Details

#entered?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/nested_context.rb', line 15

def entered?
  @depth.positive?
end

Instance Method Details

#enter

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/nested_context.rb', line 7

def enter
  push

  yield
ensure
  pop
end

#pop (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/nested_context.rb', line 25

def pop
  @depth -= 1
end

#push (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/nested_context.rb', line 21

def push
  @depth += 1
end