Module: Compass::Breadcrumb
- Defined in:
- lib/compass/breadcrumb.rb,
lib/compass/breadcrumb/strategies/http.rb,
lib/compass/breadcrumb/strategies/cookie.rb
Overview
Compass breadcrumb handling module. It leverages the configured breadcrumb strategy to fetch and push breadcrumb items.
Defined Under Namespace
Modules: Strategies
Class Method Summary collapse
-
.for(context:, max: 10) ⇒ Array<Hash>?
Fetch breadcrumb for the given context, using the configured strategy.
-
.push(context:, url:, label:) ⇒ nil
Push a new breadcrumb item for the given context, using the configured strategy.
Class Method Details
.for(context:, max: 10) ⇒ Array<Hash>?
Fetch breadcrumb for the given context, using the configured strategy.
I.e.:
Compass::Breadcrumb.for(context: current_context, max: 5)
=> [
{ url: "/home", label: "Home" },
{ url: "/section", label: "Section" },
{ url: "/section/page", label: "Page" }
]
27 28 29 |
# File 'lib/compass/breadcrumb.rb', line 27 def self.for(context:, max: 10) Compass.config..strategy&.for(context: context, max: max) end |
.push(context:, url:, label:) ⇒ nil
Push a new breadcrumb item for the given context, using the configured strategy.
I.e.:
Compass::Breadcrumb.push(
context: current_context,
url: "/section/page",
label: "Page"
)
46 47 48 |
# File 'lib/compass/breadcrumb.rb', line 46 def self.push(context:, url:, label:) Compass.config..strategy&.push(context: context, url: url, label: label) end |