class Pupa::Membership

A relationship between a person and an organization.

Attributes

area_id[RW]
end_date[RW]
label[RW]
member[RW]
on_behalf_of_id[RW]
organization_id[RW]
person_id[RW]
post_id[RW]
role[RW]
start_date[RW]

Public Instance Methods

fingerprint() click to toggle source

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.

Calls superclass method Pupa::Model#fingerprint
# 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() click to toggle source

Returns the IDs of the parties to the relationship.

@return [String] the IDs of the parties to the relationship

# File lib/pupa/models/membership.rb, line 21
def to_s
  "#{person_id} in #{organization_id}"
end