Sha256: 41df8a99fbff327a3994bd47c788355dc21a33bc27171f9bf87c05069e4ab62f

Contents?: true

Size: 872 Bytes

Versions: 12

Compression:

Stored size: 872 Bytes

Contents

module Ecom
  module Core
    class Crew < ApplicationRecord
      PERMANENT = 'Permanent'.freeze
      SUPERVISOR = 'Supervisor'.freeze
      TEMPORARY = 'Temporary'.freeze
      EMPLOYMENT_TYPES = [PERMANENT, SUPERVISOR, TEMPORARY].freeze

      before_save :set_employment_date,
                  if: proc { |c| c.employment_date.nil? }

      belongs_to :crew_type

      validates :name, :address, :qualification, :employment, :wage, :wage_in_words, presence: true
      validates :employment, inclusion: EMPLOYMENT_TYPES

      scope :by_active, ->(active) { where(active: active) }
      scope :by_qualification, ->(qualification) { where(qualification: qualification) }
      scope :by_sub_contracted, ->(sub_contracted) { where(sub_contracted: sub_contracted) }

      def set_employment_date
        self.employment_date = Date.today
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ecom_core-1.2.22 app/models/ecom/core/crew.rb
ecom_core-1.2.21 app/models/ecom/core/crew.rb
ecom_core-1.2.20 app/models/ecom/core/crew.rb
ecom_core-1.2.19 app/models/ecom/core/crew.rb
ecom_core-1.2.18 app/models/ecom/core/crew.rb
ecom_core-1.2.17 app/models/ecom/core/crew.rb
ecom_core-1.2.16 app/models/ecom/core/crew.rb
ecom_core-1.2.15 app/models/ecom/core/crew.rb
ecom_core-1.2.14 app/models/ecom/core/crew.rb
ecom_core-1.2.13 app/models/ecom/core/crew.rb
ecom_core-1.2.12 app/models/ecom/core/crew.rb
ecom_core-1.2.11 app/models/ecom/core/crew.rb