class Trestle::Toolbar::Context

The toolbar Context is the object that is yielded to a toolbar block and handles the delegation of builder methods.

Attributes

builder[R]

Public Class Methods

new(builder, enumerator, *args) click to toggle source
# File lib/trestle/toolbar/context.rb, line 7
def initialize(builder, enumerator, *args)
  @builder, @enumerator = builder, enumerator
  @args = args
end

Public Instance Methods

group() { || ... } click to toggle source
# File lib/trestle/toolbar/context.rb, line 12
def group
  if @current_group
    yield
  else
    @current_group = []
    yield
    @enumerator << @current_group
    @current_group = nil
  end
end

Private Instance Methods

method_missing(name, *args, &block) click to toggle source
# File lib/trestle/toolbar/context.rb, line 28
def method_missing(name, *args, &block)
  result = builder.send(name, *args, &block)

  if builder.builder_methods.include?(name)
    group { @current_group << result }
  else
    result
  end
end
respond_to_missing?(name, include_all=false) click to toggle source
Calls superclass method
# File lib/trestle/toolbar/context.rb, line 24
def respond_to_missing?(name, include_all=false)
  builder.respond_to?(name) || super
end