Sha256: 0f10862a93fd042bc4b289d4e3162b54aa6369f0f789e0c54d3c1470c4175bb3

Contents?: true

Size: 704 Bytes

Versions: 4

Compression:

Stored size: 704 Bytes

Contents

module Ecom
  module Core
    class Crew < ApplicationRecord
      PERMANENT = 'Permanent'.freeze
      TEMPORARY = 'Temporary'.freeze

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

      belongs_to :crew_type
      has_many :crew_times, class_name: 'Ecom::Core::CrewTime'

      validates :name, :qualification, presence: true
      validates :employment, inclusion: [PERMANENT, TEMPORARY]
      #validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT }
      #validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY }

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecom_core-1.1.8 app/models/ecom/core/crew.rb
ecom_core-1.1.7 app/models/ecom/core/crew.rb
ecom_core-1.1.6 app/models/ecom/core/crew.rb
ecom_core-1.1.5 app/models/ecom/core/crew.rb