Class: Lustr::EvalContext

Inherits:
Object
  • Object
show all
Defined in:
lib/lustr/eval_context.rb

Direct Known Subclasses

Generator, Runtime

Instance Method Summary collapse

Constructor Details

#initializeEvalContext



18
19
20
# File 'lib/lustr/eval_context.rb', line 18

def initialize
  @gadget_stack=[]
end

Instance Method Details

#current_gadgetObject



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