Class: Govspeak::ContactPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/govspeak/presenters/contact_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contactObject (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



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_idObject



12
13
14
# File 'lib/govspeak/presenters/contact_presenter.rb', line 12

def content_id
  contact[:content_id]
end

#descriptionObject



20
21
22
# File 'lib/govspeak/presenters/contact_presenter.rb', line 20

def description
  contact[:description]
end

#email_addressesObject



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_numbersObject



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_addressesObject



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

#titleObject



16
17
18
# File 'lib/govspeak/presenters/contact_presenter.rb', line 16

def title
  contact[:title]
end