Module: Compass::Breadcrumb
- Defined in:
- lib/compass/breadcrumb.rb,
lib/compass/breadcrumb/middleware.rb
Overview
Compass breadcrumb handling module. It leverages the configured breadcrumb strategy to fetch and push breadcrumb items.
Defined Under Namespace
Classes: Middleware
Class Method Summary collapse
-
.for(context: {}, max: 10) ⇒ Array<Hash>?
Fetch breadcrumb for the given context, using the configured strategy.
-
.push(context: {}, url:, label:) ⇒ Object
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_id, context: { current_user: }, max: 5)
=> [
{ url: "/home", label: "Home" },
{ url: "/section", label: "Section" },
{ url: "/section/page", label: "Page" }
]
23 24 25 |
# File 'lib/compass/breadcrumb.rb', line 23 def self.for(context: {}, max: 10) Compass.config..strategy&.for(context: context, max: max) end |
.push(context: {}, url:, label:) ⇒ Object
Push a new breadcrumb item for the given context, using the configured strategy.
I.e.:
Compass::Breadcrumb.push(
context_id,
context: { current_user: },
url: "/section/page",
label: "Page"
)
42 43 44 |
# File 'lib/compass/breadcrumb.rb', line 42 def self.push(context: {}, url:, label:) Compass.config..strategy&.push(context: context, url: url, label: label) end |