class Ilex::Context

Inject a component's instance variables into arbre's default context as well as provide implicit handling of snake-cased component names as tags

Public Class Methods

new(component, &blk) click to toggle source
Calls superclass method
# File lib/ilex/context.rb, line 10
def initialize(component, &blk)
  @component = component


  # Copy all of the instance variables from the component to the context,
  # so we have access to them when rendering
  @component.instance_variables.each do |iv|
    instance_variable_set(iv, @component.instance_variable_get(iv))
  end

  super({}, component, &blk)
end

Public Instance Methods

component_wardens() click to toggle source
# File lib/ilex/context.rb, line 27
def component_wardens
  @component_wardens ||= ComponentWardens.new(@component)
end
content() click to toggle source
# File lib/ilex/context.rb, line 23
def content
  @component.send :content
end
method_missing(method, *args, &content_block) click to toggle source
Calls superclass method
# File lib/ilex/context.rb, line 39
def method_missing(method, *args, &content_block)
  if @component.respond_to?(method)
    @component.send(method, *args, &content_block)
  elsif component_wardens[method].exists?
    render component_wardens[method].new(*args), &content_block
  else
    super
  end
end
render(*args, &blk) click to toggle source
# File lib/ilex/context.rb, line 31
def render(*args, &blk)
  helpers.render(*args, &blk)
end
respond_to_missing?(method, include_all) click to toggle source
Calls superclass method
# File lib/ilex/context.rb, line 35
def respond_to_missing?(method, include_all)
  @component.respond_to?(method) || component_wardens[method].exists? || super
end