Class: Lustr::EvalContext
- Inherits:
-
Object
- Object
- Lustr::EvalContext
- Defined in:
- lib/lustr/eval_context.rb
Instance Method Summary collapse
- #current_gadget ⇒ Object
- #for_gadget(gadget, callable) ⇒ Object
- #init_gadget(gadget, builder) ⇒ Object
-
#initialize ⇒ EvalContext
constructor
A new instance of EvalContext.
- #is_runtime? ⇒ Boolean
Constructor Details
#initialize ⇒ EvalContext
Returns a new instance of EvalContext.
18 19 20 |
# File 'lib/lustr/eval_context.rb', line 18 def initialize @gadget_stack=[] end |
Instance Method Details
#current_gadget ⇒ Object
22 23 24 |
# File 'lib/lustr/eval_context.rb', line 22 def current_gadget @gadget_stack.last end |
#for_gadget(gadget, callable) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/lustr/eval_context.rb', line 26 def for_gadget(gadget, callable) @gadget_stack.push gadget begin callable.call ensure @gadget_stack.pop if @gadget_stack.size>1 end end |
#init_gadget(gadget, builder) ⇒ Object
36 37 38 |
# File 'lib/lustr/eval_context.rb', line 36 def init_gadget(gadget, builder) # mostly for subclasses end |
#is_runtime? ⇒ Boolean
40 41 42 |
# File 'lib/lustr/eval_context.rb', line 40 def is_runtime? false end |