Class: GovukPublishingComponents::Presenters::SubscriptionLinksHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::SubscriptionLinksHelper
- Defined in:
- lib/govuk_publishing_components/presenters/subscription_links_helper.rb
Instance Attribute Summary collapse
-
#email_signup_link ⇒ Object
readonly
Returns the value of attribute email_signup_link.
-
#email_signup_link_data_attributes ⇒ Object
readonly
Returns the value of attribute email_signup_link_data_attributes.
-
#feed_box_id ⇒ Object
readonly
Returns the value of attribute feed_box_id.
-
#feed_link_box_value ⇒ Object
readonly
Returns the value of attribute feed_link_box_value.
Instance Method Summary collapse
- #component_data_is_valid? ⇒ Boolean
- #email_signup_link_text ⇒ Object
- #feed_link ⇒ Object
- #feed_link_data_attributes ⇒ Object
- #feed_link_text ⇒ Object
-
#initialize(local_assigns) ⇒ SubscriptionLinksHelper
constructor
A new instance of SubscriptionLinksHelper.
- #tracking_is_present? ⇒ Boolean
Constructor Details
#initialize(local_assigns) ⇒ SubscriptionLinksHelper
Returns a new instance of SubscriptionLinksHelper.
6 7 8 9 10 11 12 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 6 def initialize(local_assigns) @local_assigns = local_assigns @feed_box_id = "feed-reader-#{SecureRandom.hex(2)}" @email_signup_link = @local_assigns[:email_signup_link] @email_signup_link_data_attributes = @local_assigns[:email_signup_link_data_attributes] @feed_link_box_value = @local_assigns[:feed_link_box_value] end |
Instance Attribute Details
#email_signup_link ⇒ Object (readonly)
Returns the value of attribute email_signup_link.
4 5 6 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 4 def email_signup_link @email_signup_link end |
#email_signup_link_data_attributes ⇒ Object (readonly)
Returns the value of attribute email_signup_link_data_attributes.
4 5 6 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 4 def email_signup_link_data_attributes @email_signup_link_data_attributes end |
#feed_box_id ⇒ Object (readonly)
Returns the value of attribute feed_box_id.
4 5 6 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 4 def feed_box_id @feed_box_id end |
#feed_link_box_value ⇒ Object (readonly)
Returns the value of attribute feed_link_box_value.
4 5 6 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 4 def feed_link_box_value @feed_link_box_value end |
Instance Method Details
#component_data_is_valid? ⇒ Boolean
26 27 28 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 26 def component_data_is_valid? email_signup_link.present? || feed_link.present? || feed_link_box_value.present? end |
#email_signup_link_text ⇒ Object
14 15 16 17 18 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 14 def email_signup_link_text return @local_assigns[:email_signup_link_text] if @local_assigns[:email_signup_link_text] I18n.t("components.subscription_links.email_signup_link_text") end |
#feed_link ⇒ Object
34 35 36 37 38 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 34 def feed_link return "#" if feed_link_box_value @local_assigns[:feed_link] end |
#feed_link_data_attributes ⇒ Object
40 41 42 43 44 45 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 40 def feed_link_data_attributes data = @local_assigns[:feed_link_data_attributes] || {} data[:controls] = feed_box_id if feed_link_box_value data[:expanded] = "false" if feed_link_box_value data end |
#feed_link_text ⇒ Object
20 21 22 23 24 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 20 def feed_link_text return @local_assigns[:feed_link_text] if @local_assigns[:feed_link_text] I18n.t("components.subscription_links.feed_link_text") end |
#tracking_is_present? ⇒ Boolean
30 31 32 |
# File 'lib/govuk_publishing_components/presenters/subscription_links_helper.rb', line 30 def tracking_is_present? @local_assigns[:email_signup_link_data_attributes].present? || @local_assigns[:feed_link_data_attributes].present? end |