Class: Masq::Persona

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/masq/persona.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attribute_name_for_type_uri(type_uri) ⇒ Object



19
20
21
22
# File 'app/models/masq/persona.rb', line 19

def attribute_name_for_type_uri(type_uri)
  prop = mappings.detect { |i| i[1].include?(type_uri) }
  prop ? prop[0] : nil
end

.mappingsObject

Mappings for SReg names and AX Type URIs to attributes



25
26
27
# File 'app/models/masq/persona.rb', line 25

def mappings
  Masq::Engine.config.masq["attribute_mappings"]
end

.propertiesObject



15
16
17
# File 'app/models/masq/persona.rb', line 15

def properties
  mappings.keys
end

Instance Method Details

#date_of_birthObject



38
39
40
# File 'app/models/masq/persona.rb', line 38

def date_of_birth
  "#{dob_year? ? dob_year : "0000"}-#{dob_month? ? dob_month.to_s.rjust(2, "0") : "00"}-#{dob_day? ? dob_day.to_s.rjust(2, "0") : "00"}"
end

#date_of_birth=(dob) ⇒ Object



48
49
50
51
52
53
# File 'app/models/masq/persona.rb', line 48

def date_of_birth=(dob)
  res = dob.split("-")
  self.dob_year = res[0]
  self.dob_month = res[1]
  self.dob_day = res[2]
end

#fullname=(name) ⇒ Object



42
43
44
45
46
# File 'app/models/masq/persona.rb', line 42

def fullname=(name)
  self.firstname, self.surname = name.to_s.split(" ")
  self.surname ||= firstname
  self[:fullname] = name
end

#property(type) ⇒ Object

Returns the personas attribute for the given SReg name or AX Type URI



33
34
35
36
# File 'app/models/masq/persona.rb', line 33

def property(type)
  prop = Persona.mappings.detect { |i| i[1].include?(type) }
  prop ? send(prop[0]).to_s : nil
end