Sha256: 5b2a953317f3a85a84943cc3ef75b894ac3d84dd2b2d3fdaadff35111616e1de

Contents?: true

Size: 704 Bytes

Versions: 1

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_types, 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

1 entries across 1 versions & 1 rubygems

Version Path
ecom_core-1.1.4 app/models/ecom/core/crew.rb