Class: Decidim::Verifications::PostalLetter::AuthorizationPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Verifications::PostalLetter::AuthorizationPresenter
- Defined in:
- app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb
Overview
Decorator for postal letter authorizations.
Class Method Summary collapse
Instance Method Summary collapse
-
#letter_sent? ⇒ Boolean
Whether the letter with the verification code has already been sent or not.
-
#letter_sent_at ⇒ Object
Formatted time when the postal letter was sent.
-
#verification_address ⇒ Object
The address where the verification code will be sent.
-
#verification_code ⇒ Object
The verification code to be sent.
Class Method Details
.for_collection(authorizations) ⇒ Object
10 11 12 |
# File 'app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 10 def self.for_collection() .map { || new() } end |
Instance Method Details
#letter_sent? ⇒ Boolean
Whether the letter with the verification code has already been sent or not
37 38 39 |
# File 'app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 37 def letter_sent? ["verification_code"].present? end |
#letter_sent_at ⇒ Object
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 '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_address ⇒ Object
The address where the verification code will be sent
17 18 19 |
# File 'app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb', line 17 def verification_address ["address"] end |
#verification_code ⇒ Object
The verification code to be sent. It is kept in a different metadata key according to whether it has already been sent or not
25 26 27 28 29 30 31 |
# File '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 |