Class: OpenDsl::EvalStack
- Inherits:
-
Object
- Object
- OpenDsl::EvalStack
- Defined in:
- lib/open_dsl/eval_stack.rb
Instance Method Summary collapse
- #bottom ⇒ Object
- #eval(object, &blk) ⇒ Object
- #eval_and_keep(object, &blk) ⇒ Object
-
#initialize(context_binding) ⇒ EvalStack
constructor
A new instance of EvalStack.
Constructor Details
#initialize(context_binding) ⇒ EvalStack
Returns a new instance of EvalStack.
3 4 5 6 |
# File 'lib/open_dsl/eval_stack.rb', line 3 def initialize(context_binding) @stack = [] @context_binding = context_binding end |
Instance Method Details
#bottom ⇒ Object
18 19 20 |
# File 'lib/open_dsl/eval_stack.rb', line 18 def bottom @stack.last end |
#eval(object, &blk) ⇒ Object
13 14 15 16 |
# File 'lib/open_dsl/eval_stack.rb', line 13 def eval(object, &blk) eval_and_keep(object, &blk) @stack.pop end |
#eval_and_keep(object, &blk) ⇒ Object
8 9 10 11 |
# File 'lib/open_dsl/eval_stack.rb', line 8 def eval_and_keep(object, &blk) @stack.push(object) @context_binding.instance_eval(&blk) end |