Sha256: 69ccfd064c01c37a07ab58a0400323c6361795c6ab3e752ec13d21938c4f679b

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Popolo
  # A relationship between a person and an organization.
  class Membership
    include Mongoid::Document

    # An area related to the membership, e.g. an electoral riding.
    belongs_to :area, index: true, class_name: 'Popolo::Area'
    # The person who is a party to the relationship.
    belongs_to :organization, index: true, class_name: 'Popolo::Organization'
    # The organization that is a party to the relationship.
    belongs_to :person, index: true, class_name: 'Popolo::Person'

    # The role that the person fulfills in the organization. Roles should
    # preferably belong to a controlled vocabulary.
    field :role, type: String
    # The date on which the relationship began.
    field :start_date, type: String
    # The date on which the relationship ended.
    field :end_date, type: String

    validates_presence_of :organization_id, :person_id
    validates_format_of :start_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
    validates_format_of :end_date, with: /\A\d{4}(-\d{2}){0,2}\z/, allow_blank: true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
popolo-0.0.2 app/models/popolo/membership.rb
popolo-0.0.1 app/models/popolo/membership.rb