Class: Decidim::Verifications::PostalLetter::AuthorizationPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb

Overview

Decorator for postal letter authorizations.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_collection(authorizations) ⇒ Object


10
11
12
# File 'decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 10

def self.for_collection(authorizations)
  authorizations.map { |authorization| new(authorization) }
end

Instance Method Details

#letter_sent?Boolean

Whether the letter with the verification code has already been sent or not

Returns:

  • (Boolean)

37
38
39
# File 'decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 37

def letter_sent?
  ["verification_code"].present?
end

#letter_sent_atObject

Formatted time when the postal letter was sent. Or an informational string if not yet sent


45
46
47
48
49
50
51
52
53
54
55
# File 'decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 45

def letter_sent_at
  unless letter_sent?
    return I18n.t("pending_authorizations.index.not_yet_sent",
                  scope: "decidim.verifications.postal_letter.admin")
  end

  I18n.l(
    Time.zone.parse(["letter_sent_at"]),
    format: :short
  )
end

#verification_addressObject

The address where the verification code will be sent


17
18
19
# File 'decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 17

def verification_address
  ["address"]
end

#verification_codeObject

The verification code to be sent. It's kept in a different metadata key according to whether it has already been sent or not


25
26
27
28
29
30
31
# File 'decidim-verifications/app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 25

def verification_code
  if letter_sent?
    ["verification_code"]
  else
    ["pending_verification_code"]
  end
end