Class: Pupa::Membership

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_idObject

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_dateObject

Returns the value of attribute end_date.



13
14
15
# File 'lib/pupa/models/membership.rb', line 13

def end_date
  @end_date
end

#labelObject

Returns the value of attribute label.



13
14
15
# File 'lib/pupa/models/membership.rb', line 13

def label
  @label
end

#memberObject

Returns the value of attribute member.



13
14
15
# File 'lib/pupa/models/membership.rb', line 13

def member
  @member
end

#on_behalf_of_idObject

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_idObject

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_idObject

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_idObject

Returns the value of attribute post_id.



13
14
15
# File 'lib/pupa/models/membership.rb', line 13

def post_id
  @post_id
end

#roleObject

Returns the value of attribute role.



13
14
15
# File 'lib/pupa/models/membership.rb', line 13

def role
  @role
end

#start_dateObject

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

#fingerprintObject

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_sString

Returns the IDs of the parties to the relationship.

Returns:

  • (String)

    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