Sha256: dd1b078f23275e47ffb30ac5d639192103fbcc1beffb6bc2af0178c334526b13

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 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
    include Model

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

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.0.13 lib/pupa/models/organization.rb
pupa-0.0.12 lib/pupa/models/organization.rb
pupa-0.0.11 lib/pupa/models/organization.rb
pupa-0.0.10 lib/pupa/models/organization.rb
pupa-0.0.9 lib/pupa/models/organization.rb