Class: Pupa::Organization

Inherits:
Object
  • Object
show all
Includes:
Concerns::Contactable, Concerns::Identifiable, Concerns::Linkable, Concerns::Nameable, Concerns::Sourceable, Concerns::Timestamps, Model
Defined in:
lib/pupa/models/organization.rb

Overview

A group with a common purpose or reason for existence that goes beyond the set of people belonging to it.

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::Identifiable

#add_identifier, #identifiers=, #initialize

Methods included from Concerns::Nameable

#add_name, #initialize, #other_names=

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.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def area_id
  @area_id
end

#classificationObject

Returns the value of attribute classification.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def classification
  @classification
end

#dissolution_dateObject

Returns the value of attribute dissolution_date.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def dissolution_date
  @dissolution_date
end

#founding_dateObject

Returns the value of attribute founding_date.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def founding_date
  @founding_date
end

#imageObject

Returns the value of attribute image.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def image
  @image
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def name
  @name
end

#parentObject

Returns the value of attribute parent.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def parent
  @parent
end

#parent_idObject

Returns the value of attribute parent_id.



16
17
18
# File 'lib/pupa/models/organization.rb', line 16

def parent_id
  @parent_id
end

Instance Method Details

#fingerprintObject

TODO:

Parentless organizations in different jurisdictions can have the same name. Add a jurisdiction property?



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pupa/models/organization.rb', line 32

def fingerprint
  hash = super.slice(:classification, :parent_id)
  if name
    {
      '$or' => [
        hash.merge('name' => name),
        hash.merge('other_names.name' => name),
      ],
    }
  else
    hash
  end
end

#to_sString

Returns the name of the organization.

Returns:

  • (String)

    the name of the organization



26
27
28
# File 'lib/pupa/models/organization.rb', line 26

def to_s
  name
end