Sha256: 7faa23072ca5e002250205d7c6694e94a45eb7a0b862134216c7f2be68076084

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module Breadcrumble
  module ActionController
    def self.included klass
      klass.extend ClassMethods
      klass.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

      def add_crumb name, url = nil
        warn "[DEPRECATION] 'add_crumb' is deprecated. Please use 'add_breadcrumb' instead."
        add_breadcrumb name, url
      end
    end

    protected

    def add_breadcrumb name, url = nil
      @breadcrumbs ||= []
      @breadcrumbs << { name: name, url: url ? url_for(url) : nil }
    end

    def add_crumb name, url = nil
      warn "[DEPRECATION] 'add_crumb' is deprecated. Please use 'add_breadcrumb' instead."
      add_breadcrumb name, url
    end

    def breadcrumbs
      @breadcrumbs
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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