Class: GovukPublishingComponents::Presenters::InterventionHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::InterventionHelper
- Defined in:
- lib/govuk_publishing_components/presenters/intervention_helper.rb
Instance Method Summary collapse
- #accessible_text ⇒ Object
- #dismiss_link ⇒ Object
-
#initialize(local_assigns) ⇒ InterventionHelper
constructor
A new instance of InterventionHelper.
- #security_attr ⇒ Object
Constructor Details
#initialize(local_assigns) ⇒ InterventionHelper
Returns a new instance of InterventionHelper.
4 5 6 7 8 9 |
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 4 def initialize(local_assigns) @accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix") @query_string = local_assigns[:query_string] @suggestion_link_text = local_assigns[:suggestion_link_text] @suggestion_link_url = local_assigns[:suggestion_link_url] end |
Instance Method Details
#accessible_text ⇒ Object
11 12 13 14 15 |
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 11 def accessible_text @suggestion_link_text << @accessible_text_suffix unless @suggestion_link_text.include?(@accessible_text_suffix) @suggestion_link_text end |
#dismiss_link ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 17 def dismiss_link if @query_string.present? "#{@query_string}&hide-intervention=true" else "?hide-intervention=true" end end |
#security_attr ⇒ Object
25 26 27 28 29 30 |
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 25 def security_attr rel = "noopener noreferrer" rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk") rel end |