Class: WorkOrder::Factory
- Inherits:
-
Object
- Object
- WorkOrder::Factory
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/work_order/factory.rb
Overview
Builds work orders for a given submission Currently only supports single request type submissions.
Instance Attribute Summary collapse
-
#submission ⇒ Object
readonly
Returns the value of attribute submission.
Instance Method Summary collapse
- #create_work_orders! ⇒ Object
-
#initialize(submission) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(submission) ⇒ Factory
Returns a new instance of Factory.
14 15 16 |
# File 'app/models/work_order/factory.rb', line 14 def initialize(submission) @submission = submission end |
Instance Attribute Details
#submission ⇒ Object (readonly)
Returns the value of attribute submission.
8 9 10 |
# File 'app/models/work_order/factory.rb', line 8 def submission @submission end |
Instance Method Details
#create_work_orders! ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/models/work_order/factory.rb', line 18 def create_work_orders! requests .group_by(&:asset_id) .map do |_asset_id, requests| state = requests.first.state WorkOrder.create!(work_order_type:, requests:, state:) end end |