Sha256: 7ac5d51054cfe83aaae16b830b9303751cc9464aa2d066a5b550ef2710d5b840

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

module Pupa
  # A position that exists independent of the person holding it.
  class Post
    include Model

    self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'post.json'), __dir__)

    include Concerns::Timestamps
    include Concerns::Sourceable
    include Concerns::Contactable
    include Concerns::Linkable

    attr_accessor :label, :other_label, :role, :organization_id, :area_id, :start_date, :end_date
    dump          :label, :other_label, :role, :organization_id, :area_id, :start_date, :end_date

    foreign_key :organization_id, :area_id

    # Returns the post's label or role and organization ID.
    #
    # @return [String] the post's label or role and organization ID
    def to_s
      "#{label || role} in #{organization_id}"
    end

    # A post should have a unique label within an organization, through it may
    # share a label with a historical post.
    def fingerprint
      super.slice(:label, :organization_id, :end_date)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pupa-0.2.4 lib/pupa/models/post.rb