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
35 36 37 |
# File 'app/models/ecom/core/task_template.rb', line 35 def crew_types resource_types.where(type: 'Ecom::Core::CrewType') end |
#equipment_types ⇒ Object
43 44 45 |
# File 'app/models/ecom/core/task_template.rb', line 43 def equipment_types resource_types.where(type: 'Ecom::Core::EquipmentType') end |
#full_name ⇒ Object
28 29 30 31 32 33 |
# File 'app/models/ecom/core/task_template.rb', line 28 def full_name parent_name = parent&.name return name unless parent_name "#{name} - #{parent_name}" end |
#material_types ⇒ Object
39 40 41 |
# File 'app/models/ecom/core/task_template.rb', line 39 def material_types resource_types.where(type: 'Ecom::Core::MaterialType') end |
#percentage_contribution_sum_validator ⇒ Object
47 48 49 50 51 52 |
# File 'app/models/ecom/core/task_template.rb', line 47 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 |