Class: Trestle::Toolbar

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Defined in:
lib/trestle/toolbar.rb,
lib/trestle/toolbar/item.rb,
lib/trestle/toolbar/menu.rb,
lib/trestle/toolbar/builder.rb,
lib/trestle/toolbar/context.rb

Defined Under Namespace

Classes: Block, Builder, Button, Context, Dropdown, Item, Link, Menu

Instance Method Summary collapse

Constructor Details

#initialize(builder = Builder) ⇒ Toolbar

Returns a new instance of Toolbar.



15
16
17
18
# File 'lib/trestle/toolbar.rb', line 15

def initialize(builder=Builder)
  @builder = builder
  clear!
end

Instance Method Details

#append(&block) ⇒ Object



33
34
35
# File 'lib/trestle/toolbar.rb', line 33

def append(&block)
  @blocks.push(Block.new(&block))
end

#clear!Object



20
21
22
# File 'lib/trestle/toolbar.rb', line 20

def clear!
  @blocks = []
end

#groups(template, *args) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/trestle/toolbar.rb', line 24

def groups(template, *args)
  Enumerator.new do |y|
    @blocks.each do |block|
      builder = @builder.new(template, *args)
      block.evaluate(builder, template, y, *args)
    end
  end
end

#prepend(&block) ⇒ Object



37
38
39
# File 'lib/trestle/toolbar.rb', line 37

def prepend(&block)
  @blocks.unshift(Block.new(&block))
end