Class: Ecom::Core::TaskTemplate
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Ecom::Core::TaskTemplate
- Defined in:
- app/models/ecom/core/task_template.rb
Instance Method Summary collapse
- #crew_types ⇒ Object
- #equipment_types ⇒ Object
- #full_name ⇒ Object
- #material_types ⇒ Object
- #percentage_contribution_sum_validator ⇒ Object
Instance Method Details
#crew_types ⇒ Object
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_types ⇒ Object
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_name ⇒ Object
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_types ⇒ Object
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_validator ⇒ Object
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 |