Sha256: dd4ffbc112a308e304b75a7c4369c98375855d9dfcf13a78835f2f7c399b8810

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 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.append(&block) if block_given?
        toolbar
      end

      def default_toolbar_builder
        Toolbar::Builder
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.10.1 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.10.0 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.10.0.pre2 app/controllers/concerns/trestle/controller/toolbars.rb
trestle-0.10.0.pre app/controllers/concerns/trestle/controller/toolbars.rb