Class: GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnAncestors
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnAncestors
- Defined in:
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb
Class Method Summary collapse
Instance Method Summary collapse
- #breadcrumbs ⇒ Object
-
#initialize(content_item) ⇒ ContentBreadcrumbsBasedOnAncestors
constructor
A new instance of ContentBreadcrumbsBasedOnAncestors.
Constructor Details
#initialize(content_item) ⇒ ContentBreadcrumbsBasedOnAncestors
Returns a new instance of ContentBreadcrumbsBasedOnAncestors.
9 10 11 |
# File 'lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb', line 9 def initialize(content_item) @content_item = ContentItem.new(content_item) end |
Class Method Details
.call(content_item) ⇒ Object
5 6 7 |
# File 'lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb', line 5 def self.call(content_item) new(content_item). end |
Instance Method Details
#breadcrumbs ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb', line 13 def ordered_ancestors = all_ancestors.map do |ancestor| { title: ancestor.title, url: ancestor.base_path } end ordered_ancestors << { title: "Home", url: "/" } ordered_ancestors.reverse! ordered_ancestors end |