Sha256: 41243f52023162a3881de20a5b1af5b8dc644f9eb720743e47f1bfbea5c03346

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literals: true

module Jobshop
  class Employment < ApplicationRecord
    self.primary_keys = %i[ organization_id employment_id ]

    after_initialize { self.employment_id ||= SecureRandom.uuid if new_record? }
    after_create { reload }

    belongs_to :organization, inverse_of: :employments

    belongs_to :employee, inverse_of: :employments,
      foreign_key: %i[ organization_id employee_id ]

    default_scope { order(ended_on: :desc, started_on: :desc) }

    scope :active, -> {
      where(ended_on: nil)
    }

    scope :inactive, -> {
      where.not(ended_on: nil)
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 app/models/jobshop/employment.rb