Class: Masq::Persona
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Masq::Persona
- Defined in:
- app/models/masq/persona.rb
Class Method Summary collapse
- .attribute_name_for_type_uri(type_uri) ⇒ Object
-
.mappings ⇒ Object
Mappings for SReg names and AX Type URIs to attributes.
- .properties ⇒ Object
Instance Method Summary collapse
- #date_of_birth ⇒ Object
- #date_of_birth=(dob) ⇒ Object
- #fullname=(name) ⇒ Object
-
#property(type) ⇒ Object
Returns the personas attribute for the given SReg name or AX Type URI.
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 |
.mappings ⇒ Object
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 |
.properties ⇒ Object
15 16 17 |
# File 'app/models/masq/persona.rb', line 15 def properties mappings.keys end |
Instance Method Details
#date_of_birth ⇒ Object
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 |