class GovukPublishingComponents::Presenters::BreadcrumbSelector
Attributes
content_item[R]
request[R]
Public Class Methods
new(content_item, request, prioritise_taxon_breadcrumbs)
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 6 def initialize(content_item, request, prioritise_taxon_breadcrumbs) @content_item = content_item @request = request @prioritise_taxon_breadcrumbs = prioritise_taxon_breadcrumbs end
Public Instance Methods
step_by_step()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 16 def step_by_step best_match_option[:step_by_step] end
Private Instance Methods
best_match_option()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 33 def best_match_option return content_item_options unless content_item_navigation.html_publication_with_parent? { step_by_step: parent_is_step_by_step?, breadcrumbs: parent_is_step_by_step? ? parent_breadcrumbs.first : parent_breadcrumbs, } end
content_item_options()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 106 def content_item_options @content_item_options ||= options(content_item_navigation) end
options(navigation)
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 42 def options(navigation) if navigation.content_tagged_to_a_finder? { step_by_step: false, breadcrumbs: navigation.finder_breadcrumbs, } elsif navigation.content_tagged_to_current_step_by_step? { step_by_step: true, breadcrumbs: navigation.step_nav_helper.header, } elsif navigation.content_is_tagged_to_a_live_taxon? && prioritise_taxon_breadcrumbs { step_by_step: false, breadcrumbs: navigation.taxon_breadcrumbs, } elsif navigation.content_tagged_to_mainstream_browse_pages? { step_by_step: false, breadcrumbs: navigation.breadcrumbs, } elsif navigation.content_is_travel_advice? { step_by_step: false, breadcrumbs: navigation.breadcrumbs, } elsif navigation.content_has_a_topic? { step_by_step: false, breadcrumbs: navigation.topic_breadcrumbs, } elsif navigation.use_taxon_breadcrumbs? { step_by_step: false, breadcrumbs: navigation.taxon_breadcrumbs, } elsif navigation.breadcrumbs.any? { step_by_step: false, breadcrumbs: navigation.breadcrumbs, } else {} end end
parent_is_step_by_step?()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 120 def parent_is_step_by_step? parent_item_options[:step_by_step] end
parent_item()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 96 def parent_item @parent_item ||= Services.content_store.content_item(content_item_navigation.parent_api_path) rescue GdsApi::ContentStore::ItemNotFound # Do nothing end
parent_item_options()
click to toggle source
# File lib/govuk_publishing_components/presenters/breadcrumb_selector.rb, line 102 def parent_item_options @parent_item_options ||= options(parent_item_navigation) end