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.
20 21 22 23 24 25 26 |
# File 'app/models/egov_utils/person.rb', line 20 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
28 29 30 31 32 33 34 35 |
# File 'app/models/egov_utils/person.rb', line 28 def person_entity case person_type when 'natural' natural_person when 'legal' legal_person end end |
#person_entity=(entity) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/egov_utils/person.rb', line 37 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
48 49 50 |
# File 'app/models/egov_utils/person.rb', line 48 def residence addresses.last end |
#residence=(address) ⇒ Object
52 53 54 |
# File 'app/models/egov_utils/person.rb', line 52 def residence=(address) addresses << address end |
#to_s ⇒ Object
56 57 58 |
# File 'app/models/egov_utils/person.rb', line 56 def to_s person_entity.to_s end |