Class: Govspeak::ContactPresenter
- Inherits:
-
Object
- Object
- Govspeak::ContactPresenter
- Defined in:
- lib/govspeak/presenters/contact_presenter.rb
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
Instance Method Summary collapse
- #contact_form_links ⇒ Object
- #content_id ⇒ Object
- #description ⇒ Object
- #email_addresses ⇒ Object
-
#initialize(contact) ⇒ ContactPresenter
constructor
A new instance of ContactPresenter.
- #phone_numbers ⇒ Object
- #post_addresses ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(contact) ⇒ ContactPresenter
Returns a new instance of ContactPresenter.
8 9 10 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 8 def initialize(contact) @contact = ActiveSupport::HashWithIndifferentAccess.new(contact) end |
Instance Attribute Details
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
6 7 8 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 6 def contact @contact end |
Instance Method Details
#contact_form_links ⇒ Object
45 46 47 48 49 50 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 45 def contact_form_links @contact_form_links ||= begin contact_form_links = contact.dig(:details, :contact_form_links) || [] contact_form_links.select { |c| c[:link].present? } end end |
#content_id ⇒ Object
12 13 14 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 12 def content_id contact[:content_id] end |
#description ⇒ Object
20 21 22 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 20 def description contact[:description] end |
#email_addresses ⇒ Object
31 32 33 34 35 36 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 31 def email_addresses @email_addresses ||= begin emails = contact.dig(:details, :email_addresses) || [] emails.select { |e| e[:email].present? } end end |
#phone_numbers ⇒ Object
38 39 40 41 42 43 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 38 def phone_numbers @phone_numbers ||= begin phone_numbers = contact.dig(:details, :phone_numbers) || [] phone_numbers.select { |p| p[:number].present? } end end |
#post_addresses ⇒ Object
24 25 26 27 28 29 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 24 def post_addresses @post_addresses ||= begin addresses = contact.dig(:details, :post_addresses) || [] filter_post_addresses(addresses) end end |
#title ⇒ Object
16 17 18 |
# File 'lib/govspeak/presenters/contact_presenter.rb', line 16 def title contact[:title] end |