Module: Rbexy::ComponentContext

Included in:
Rails::ControllerHelper, Runtime
Defined in:
lib/rbexy/component_context.rb

Instance Method Summary collapse

Instance Method Details

#create_context(name, value) ⇒ Object



7
8
9
# File 'lib/rbexy/component_context.rb', line 7

def create_context(name, value)
  rbexy_context.last[name] = value
end

#rbexy_contextObject



3
4
5
# File 'lib/rbexy/component_context.rb', line 3

def rbexy_context
  @rbexy_context ||= [{}]
end

#use_context(name) ⇒ Object



11
12
13
14
15
16
# File 'lib/rbexy/component_context.rb', line 11

def use_context(name)
  index = rbexy_context.rindex { |c| c.has_key?(name) }
  index ?
    rbexy_context[index][name] :
    raise(ContextNotFound, "no parent context `#{name}`")
end