Module: Roles::Person
- Extended by:
- ActiveSupport::Concern
- Included in:
- Role
- Defined in:
- app/models/concerns/roles/person.rb
Instance Method Summary collapse
- #check_for_last ⇒ Object protected
- #person_role? ⇒ Boolean protected
-
#update_person_year_metadata ⇒ Object
protected
Could be spun out to sublclasses but.
-
#vet_person ⇒ Object
protected
See /app/models/person.rb for a definition of vetted.
-
#year_active_year ⇒ Year?
protected
The largest year attribte in the RoleObject.
Instance Method Details
#check_for_last ⇒ Object (protected)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/roles/person.rb', line 25 def check_for_last if is_last_role? && role_object_type == 'Source' add_touch = false if type == 'SourceAuthor' role_object.update_columns(author: nil, cached_author_string: nil) add_touch = true end if type == 'SourceEditor' add_touch = true role_object.update_columns(editor: nil) end role_object.touch else role_object.send(:set_cached) if role_object.respond_to?(:set_cached, true) end end |
#person_role? ⇒ Boolean (protected)
21 22 23 |
# File 'app/models/concerns/roles/person.rb', line 21 def person_role? person.present? && organization.blank? end |
#update_person_year_metadata ⇒ Object (protected)
Could be spun out to sublclasses but
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/concerns/roles/person.rb', line 62 def if y = year_active_year yas = [y, person.year_active_start].compact.map(&:to_i).min yae = [y, person.year_active_end].compact.map(&:to_i).max person.year_active_start = yas person.year_active_end = yae if person.valid? person.update_columns(year_active_start: yas, year_active_end: yae) else person.year_active_start = person.year_active_start_before_last_save person.year_active_end = person.year_active_end_before_last_save end end true end |
#vet_person ⇒ Object (protected)
See /app/models/person.rb for a definition of vetted
43 44 45 46 47 48 49 |
# File 'app/models/concerns/roles/person.rb', line 43 def vet_person # Check whether there are one or more *other* roles besides this one, # i.e. there are at least *2* for person_id if Role.where(person_id:).where.not(id:).any? person.update_column(:type, 'Person::Vetted') end end |
#year_active_year ⇒ Year? (protected)
The largest year attribte in the RoleObject
Set in Role subclasses
57 58 59 |
# File 'app/models/concerns/roles/person.rb', line 57 def year_active_year nil end |