Sha256: 8e588cda9183b58ddea4f6a5ddbcc974d8604df6f766af6546f77a43d1925b78

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

module RailsCrumbs
  module RailsCrumbsController

    def set_railscrumb(name, path, options = {})
      case path
        when Symbol
          path = self.send(path)
        when Proc
          path = path.call(self)
        else
          path = self.url_for(path)
      end
      self.railscrumbs << Crumb.new(name, path, options)
    end

    def railscrumbs
      @railscrumbs ||= []
    end

    def self.included(base)
      base.send(:extend, ClassMethods)
    end

    module ClassMethods

      def set_railscrumb(name, path = nil, options = {})
        only = options.delete(:only){ [] }
        if only.empty?
          filter_options = {}
        else
          filter_options = {:only => only}
        end

        before_filter(filter_options) do |controller|
          controller.send(:set_railscrumb, name, path, options)
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_crumbs-1.0.0 lib/rails_crumbs/controller.rb