Sha256: 4ae21c0a658a52a58762b177cd07751d57fff64e0ed064daea3180df6aeb35c1

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecom_core-1.2.10 app/models/ecom/core/crew.rb
ecom_core-1.2.9 app/models/ecom/core/crew.rb
ecom_core-1.2.7 app/models/ecom/core/crew.rb