Sha256: a4c0401e0ee31f19d9f8a720a908c6450f1c7f07cad46930bf0ee9d547fc8b98

Contents?: true

Size: 862 Bytes

Versions: 14

Compression:

Stored size: 862 Bytes

Contents

module Trestle
  class Toolbar
    class Builder
      def initialize(template)
        @template = template
      end

      def button(label, options={}, &block)
        Button.new(@template, label, options, &block)
      end

      def link(label, instance_or_url={}, options={}, &block)
        Link.new(@template, label, instance_or_url, options, &block)
      end

      def dropdown(label=nil, options={}, &block)
        Dropdown.new(@template, label, options, &block)
      end

      # Only methods explicitly tagged as builder methods will be automatically
      # appended to the toolbar when called by Toolbar::Context.

      class_attribute :builder_methods
      self.builder_methods = []

      def self.builder_method(*methods)
        self.builder_methods += methods
      end

      builder_method :button, :link, :dropdown
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trestle-0.10.0 lib/trestle/toolbar/builder.rb
trestle-0.10.0.pre2 lib/trestle/toolbar/builder.rb
trestle-0.10.0.pre lib/trestle/toolbar/builder.rb
trestle-0.9.8 lib/trestle/toolbar/builder.rb
trestle-0.9.7 lib/trestle/toolbar/builder.rb
trestle-0.9.6 lib/trestle/toolbar/builder.rb
trestle-0.9.5 lib/trestle/toolbar/builder.rb
trestle-0.9.4 lib/trestle/toolbar/builder.rb
trestle-0.9.3 lib/trestle/toolbar/builder.rb
trestle-0.9.2 lib/trestle/toolbar/builder.rb
trestle-0.9.1 lib/trestle/toolbar/builder.rb
trestle-0.9.0 lib/trestle/toolbar/builder.rb
trestle-0.8.13 lib/trestle/toolbar/builder.rb
trestle-0.8.12 lib/trestle/toolbar/builder.rb