Module: Trufina::Elements::EasyElementAccess

Included in:
AccessResponseGroup, Name, ResidenceAddressRequest, ResidenceAddressResponse
Defined in:
lib/elements.rb

Instance Method Summary collapse

Instance Method Details

#present_and_verifiedObject

Shortcut to collecting any information that’s present and available



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/elements.rb', line 73

def present_and_verified
  yes = {}
  self.class.elements.map(&:method_name).each do |p|
    next unless val = self.send(p)
    element = self.class.elements.detect{|e| e.method_name == p}
    
    if val.respond_to?(:present_and_verified)
      yes[p.to_sym] = val.present_and_verified
    elsif element.options[:single]
      yes[p.to_sym] = val if val.state == 'verified' && val.status == 'present'
    else # street_addresses is an array...
      values = []
      val.each do |array_item|
        values << array_item if array_item.state == 'verified' && array_item.status == 'present'
      end
      yes[p.to_sym] = values
    end
  end
  yes
end