Class: Decidim::Verifications::IdDocuments::InformationForm

Inherits:
AuthorizationHandler show all
Defined in:
app/forms/decidim/verifications/id_documents/information_form.rb

Overview

A form object to be used as the base for identity document verification

Instance Method Summary collapse

Methods inherited from AuthorizationHandler

#authorization_attributes, #duplicate, #form_attributes, handler_for, handler_name, #metadata, #to_partial_path, #transferrable?, #unique?, #unique_id, #verification_attachment

Instance Method Details

#document_types_for_selectObject



44
45
46
47
48
49
50
51
# File 'app/forms/decidim/verifications/id_documents/information_form.rb', line 44

def document_types_for_select
  document_types.map do |type|
    [
      I18n.t(type.downcase, scope: "decidim.verifications.id_documents"),
      type
    ]
  end
end

#handler_nameObject



26
27
28
# File 'app/forms/decidim/verifications/id_documents/information_form.rb', line 26

def handler_name
  "id_documents"
end

#map_model(model) ⇒ Object



30
31
32
33
34
# File 'app/forms/decidim/verifications/id_documents/information_form.rb', line 30

def map_model(model)
  self.document_type = model.["document_type"]
  self.document_number = model.["document_number"]
  self.verification_type = model.["verification_type"].presence || "online"
end

#uses_online_method?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/forms/decidim/verifications/id_documents/information_form.rb', line 53

def uses_online_method?
  verification_type == "online"
end

#verification_metadataObject



36
37
38
39
40
41
42
# File 'app/forms/decidim/verifications/id_documents/information_form.rb', line 36

def 
  {
    "document_type" => document_type,
    "document_number" => document_number,
    "verification_type" => verification_type
  }
end