Sha256: a349f26e75d140d5008ff86a9cc0b934a9231e29c25d97f31fcd1f3480503ef0

Contents?: true

Size: 861 Bytes

Versions: 69

Compression:

Stored size: 861 Bytes

Contents

module Ecom
  module Core
    class TaskTemplate < ApplicationRecord
      has_ancestry

      belongs_to :task_template_type
      has_one :work_product_template
      has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'

      validates :name, :code, presence: true
      validates :code, uniqueness: true
      delegate(:name, to: :task_template_type, prefix: true)

      def full_name
        parent_name = parent&.name
        return name unless parent_name

        "#{name} - #{parent_name}"
      end

      def crew_types
        resource_types.where(type: 'Ecom::Core::CrewType')
      end

      def material_types
        resource_types.where(type: 'Ecom::Core::MaterialType')
      end

      def equipment_types
        resource_types.where(type: 'Ecom::Core::EquipmentType')
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
ecom_core-1.1.22 app/models/ecom/core/task_template.rb
ecom_core-1.1.21 app/models/ecom/core/task_template.rb
ecom_core-1.1.20 app/models/ecom/core/task_template.rb
ecom_core-1.1.19 app/models/ecom/core/task_template.rb
ecom_core-1.1.18 app/models/ecom/core/task_template.rb
ecom_core-1.1.17 app/models/ecom/core/task_template.rb
ecom_core-1.1.16 app/models/ecom/core/task_template.rb
ecom_core-1.1.15 app/models/ecom/core/task_template.rb
ecom_core-1.1.14 app/models/ecom/core/task_template.rb
ecom_core-1.1.13 app/models/ecom/core/task_template.rb
ecom_core-1.1.12 app/models/ecom/core/task_template.rb
ecom_core-1.1.11 app/models/ecom/core/task_template.rb
ecom_core-1.1.10 app/models/ecom/core/task_template.rb
ecom_core-1.1.9 app/models/ecom/core/task_template.rb
ecom_core-1.1.8 app/models/ecom/core/task_template.rb
ecom_core-1.1.7 app/models/ecom/core/task_template.rb
ecom_core-1.1.6 app/models/ecom/core/task_template.rb
ecom_core-1.1.5 app/models/ecom/core/task_template.rb
ecom_core-1.1.4 app/models/ecom/core/task_template.rb
ecom_core-1.1.3 app/models/ecom/core/task_template.rb