Class: EgovUtils::Person
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- EgovUtils::Person
- Defined in:
- app/models/egov_utils/person.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Person
constructor
A new instance of Person.
- #person_entity ⇒ Object
- #person_entity=(entity) ⇒ Object
- #residence ⇒ Object
- #residence=(address) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Person
Returns a new instance of Person.
22 23 24 25 26 27 28 |
# File 'app/models/egov_utils/person.rb', line 22 def initialize(attributes = {}) if attributes&.fetch(:remote_id, nil).present? super(attributes.slice(:remote_id, :person_type)) else super end end |
Instance Method Details
#person_entity ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/models/egov_utils/person.rb', line 30 def person_entity case person_type when 'natural' natural_person when 'legal' legal_person end end |
#person_entity=(entity) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/egov_utils/person.rb', line 39 def person_entity=(entity) case person_type when 'natural' self.natural_person = entity self.legal_person = nil when 'legal' self.legal_person = entity self.natural_person = nil end end |
#residence ⇒ Object
50 51 52 |
# File 'app/models/egov_utils/person.rb', line 50 def residence addresses.last end |
#residence=(address) ⇒ Object
54 55 56 |
# File 'app/models/egov_utils/person.rb', line 54 def residence=(address) addresses << address end |
#to_s ⇒ Object
58 59 60 |
# File 'app/models/egov_utils/person.rb', line 58 def to_s person_entity.to_s end |