Sha256: 5100a8b1eacab33e8650bff04f8501881ba008d376252495bf0c6fec9ccd9b6a
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
module Breadcrumble module ActionController extend ActiveSupport::Concern included do helper_method :add_breadcrumb, :breadcrumbs, :breadcrumb_trails end module ClassMethods def add_breadcrumb name, url = nil, filter_options = {} before_filter(filter_options) do |controller| controller.send :add_breadcrumb, name, url end end def add_breadcrumb_to name, url, trail_index, filter_options = {} before_filter(filter_options) do |controller| controller.send :add_breadcrumb_to, name, url, trail_index end end def add_breadcrumbs *args before_filter do |controller| args.each do |arg| controller.send :add_breadcrumb, arg[0], arg[1] end end end end protected def add_breadcrumb name, url = nil add_breadcrumb_to name, url, 0 end def add_breadcrumb_to name, url, trail_index self.breadcrumb_trails @breadcrumb_trails[trail_index] ||= [] @breadcrumb_trails[trail_index] << { 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 add_breadcrumbs *args args.each do |arg| add_breadcrumb arg[0], arg[1] end end def breadcrumb_trails @breadcrumb_trails ||= [] end def breadcrumbs self.breadcrumb_trails.first || [] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
breadcrumble-4.0.0 | lib/breadcrumble/action_controller.rb |
breadcrumble-3.0.7 | lib/breadcrumble/action_controller.rb |
breadcrumble-3.0.6 | lib/breadcrumble/action_controller.rb |