Sha256: efe04308ed75a7b23d3c0e274328a4428d385a8a37e90e6224b39d8857fc42e9

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

module Pupa
  # A group with a common purpose or reason for existence that goes beyond the set
  # of people belonging to it.
  class Organization < Base
    self.schema = 'popolo/organization'

    include Concerns::Timestamps
    include Concerns::Sourceable
    include Concerns::Nameable
    include Concerns::Identifiable
    include Concerns::Contactable
    include Concerns::Linkable

    attr_accessor :name, :classification, :parent_id, :parent, :founding_date,
      :dissolution_date, :image

    foreign_key :parent_id

    foreign_object :parent

    # Returns the name of the organization.
    #
    # @return [String] the name of the organization
    def to_s
      name
    end

    # @todo Parentless organizations in different jurisdictions can have the
    #   same name. Add a `jurisdiction` property?
    def fingerprint
      hash = super.slice(:classification, :parent_id)
      {
        '$or' => [
          hash.merge('name' => name),
          hash.merge('other_names.name' => name),
        ],
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pupa-0.0.8 lib/pupa/models/organization.rb
pupa-0.0.7 lib/pupa/models/organization.rb
pupa-0.0.6 lib/pupa/models/organization.rb
pupa-0.0.5 lib/pupa/models/organization.rb
pupa-0.0.4 lib/pupa/models/organization.rb
pupa-0.0.3 lib/pupa/models/organization.rb
pupa-0.0.2 lib/pupa/models/organization.rb
pupa-0.0.1 lib/pupa/models/organization.rb