Sha256: ae6ad009893e0efd4861fc83e502dd61ef26d86785043a8316e9555fd9de74d1

Contents?: true

Size: 631 Bytes

Versions: 7

Compression:

Stored size: 631 Bytes

Contents

module Trestle
  module Controller
    module Toolbars
      extend ActiveSupport::Concern

      included do
        helper_method :toolbars
        helper_method :toolbar
      end

    protected
      def toolbars
        @_toolbars ||= {}
      end

      def toolbar(name, options={}, &block)
        builder = options[:builder] || default_toolbar_builder

        toolbar = (toolbars[name.to_s] ||= Toolbar.new(builder))
        toolbar.clear! if options[:clear]
        toolbar.prepend(&block) if block_given?
        toolbar
      end

      def default_toolbar_builder
        Toolbar::Builder
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
trestle-0.9.8 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.7 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.6 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.5 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.4 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.3 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.9.2 lib/trestle/controller/toolbars.rb