Class: Pupa::Membership
- Inherits:
-
Object
- Object
- Pupa::Membership
- Includes:
- Concerns::Contactable, Concerns::Linkable, Concerns::Sourceable, Concerns::Timestamps, Model
- Defined in:
- lib/pupa/models/membership.rb
Overview
A relationship between a person and an organization.
Instance Attribute Summary collapse
-
#area_id ⇒ Object
Returns the value of attribute area_id.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#label ⇒ Object
Returns the value of attribute label.
-
#member ⇒ Object
Returns the value of attribute member.
-
#on_behalf_of_id ⇒ Object
Returns the value of attribute on_behalf_of_id.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#person_id ⇒ Object
Returns the value of attribute person_id.
-
#post_id ⇒ Object
Returns the value of attribute post_id.
-
#role ⇒ Object
Returns the value of attribute role.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#fingerprint ⇒ Object
A person's relationship with an organization must have a unique label, though it may share a label with a historical relationship.
-
#to_s ⇒ String
Returns the IDs of the parties to the relationship.
Methods included from Concerns::Linkable
#add_link, #initialize, #links=
Methods included from Concerns::Contactable
#add_contact_detail, #contact_details=, #initialize
Methods included from Concerns::Sourceable
#add_source, #initialize, #sources=
Methods included from Model
#==, #[], #[]=, #_id=, #add_extra, #extras=, #foreign_properties, #initialize, #to_h, #validate!
Instance Attribute Details
#area_id ⇒ Object
Returns the value of attribute area_id.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def area_id @area_id end |
#end_date ⇒ Object
Returns the value of attribute end_date.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def end_date @end_date end |
#label ⇒ Object
Returns the value of attribute label.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def label @label end |
#member ⇒ Object
Returns the value of attribute member.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def member @member end |
#on_behalf_of_id ⇒ Object
Returns the value of attribute on_behalf_of_id.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def on_behalf_of_id @on_behalf_of_id end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def organization_id @organization_id end |
#person_id ⇒ Object
Returns the value of attribute person_id.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def person_id @person_id end |
#post_id ⇒ Object
Returns the value of attribute post_id.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def post_id @post_id end |
#role ⇒ Object
Returns the value of attribute role.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def role @role end |
#start_date ⇒ Object
Returns the value of attribute start_date.
13 14 15 |
# File 'lib/pupa/models/membership.rb', line 13 def start_date @start_date end |
Instance Method Details
#fingerprint ⇒ Object
A person's relationship with an organization must have a unique label, though it may share a label with a historical relationship. Similarly, a person may hold a post in an organization multiple times historically but not simultaneously.
29 30 31 32 33 34 35 36 37 |
# File 'lib/pupa/models/membership.rb', line 29 def fingerprint hash = super { '$or' => [ hash.slice(:label, :person_id, :organization_id, :end_date), hash.slice(:person_id, :organization_id, :post_id, :end_date), ], } end |
#to_s ⇒ String
Returns the IDs of the parties to the relationship.
21 22 23 |
# File 'lib/pupa/models/membership.rb', line 21 def to_s "#{person_id} in #{organization_id}" end |