Class: Ecom::Core::TaskTemplate

Inherits:
ApplicationRecord show all
Defined in:
app/models/ecom/core/task_template.rb

Instance Method Summary collapse

Instance Method Details

#crew_typesObject



36
37
38
# File 'app/models/ecom/core/task_template.rb', line 36

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

#equipment_typesObject



44
45
46
# File 'app/models/ecom/core/task_template.rb', line 44

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

#full_nameObject



29
30
31
32
33
34
# File 'app/models/ecom/core/task_template.rb', line 29

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

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

#material_typesObject



40
41
42
# File 'app/models/ecom/core/task_template.rb', line 40

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

#percentage_contribution_sum_validatorObject



48
49
50
51
52
53
# File 'app/models/ecom/core/task_template.rb', line 48

def percentage_contribution_sum_validator
  return if percentage_contribution.nil?

  sum = siblings.sum(:percentage_contribution)
  errors.add(:task, 'Sum of percentage contributions has to be 100') if sum > 100
end