Sha256: 2ee48c4f85db4bfd3ccd6660aaa909a667a28816794de548317c8a7ed1268ede

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Breadcrumble
  module ActionController
    extend ActiveSupport::Concern

    included do
      helper_method :add_breadcrumb, :breadcrumbs
    end

    module ClassMethods
      def add_breadcrumb name, url = nil
        before_filter do |controller|
          controller.send :add_breadcrumb, name, url
        end
      end
    end

    protected

    def add_breadcrumb name, url = nil
      @breadcrumbs ||= []
      @breadcrumbs << {
        name: case name
              when Proc then name.call(self)
              else name
              end,
        url:  case url
              when Proc then url.call(self)
              else url ? url_for(url) : nil
              end
      }
    end

    def breadcrumbs
      @breadcrumbs
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumble-3.0.1 lib/breadcrumble/action_controller.rb