Class: Submission::FlexibleRequestGraph::RequestChain
- Inherits:
-
Object
- Object
- Submission::FlexibleRequestGraph::RequestChain
- Defined in:
- app/models/submission/flexible_request_graph.rb
Instance Attribute Summary collapse
-
#built ⇒ Object
(also: #built?)
readonly
Returns the value of attribute built.
-
#multiplexed ⇒ Object
(also: #multiplexed?)
readonly
Returns the value of attribute multiplexed.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#preplexed ⇒ Object
(also: #preplexed?)
readonly
Returns the value of attribute preplexed.
-
#source_assets_qc_metrics ⇒ Object
readonly
Returns the value of attribute source_assets_qc_metrics.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(order, source_assets, multiplexing_assets) ⇒ RequestChain
constructor
A new instance of RequestChain.
-
#multiplexing_assets ⇒ Object
multiplexing_assets returns @multiplexing_assets if present otherwise it yields to any presented block and assumes it returns the multiplexing_assets.
Constructor Details
#initialize(order, source_assets, multiplexing_assets) ⇒ RequestChain
Returns a new instance of RequestChain.
22 23 24 25 26 27 28 29 |
# File 'app/models/submission/flexible_request_graph.rb', line 22 def initialize(order, source_assets, multiplexing_assets) @order = order @source_assets_qc_metrics = source_assets.map { |asset| Doublet.new(asset, asset.latest_stock_metrics(product)) } @multiplexing_assets = multiplexing_assets @preplexed = multiplexing_assets.present? @built = false @multiplexed = false end |
Instance Attribute Details
#built ⇒ Object (readonly) Also known as: built?
Returns the value of attribute built.
15 16 17 |
# File 'app/models/submission/flexible_request_graph.rb', line 15 def built @built end |
#multiplexed ⇒ Object (readonly) Also known as: multiplexed?
Returns the value of attribute multiplexed.
15 16 17 |
# File 'app/models/submission/flexible_request_graph.rb', line 15 def multiplexed @multiplexed end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
15 16 17 |
# File 'app/models/submission/flexible_request_graph.rb', line 15 def order @order end |
#preplexed ⇒ Object (readonly) Also known as: preplexed?
Returns the value of attribute preplexed.
15 16 17 |
# File 'app/models/submission/flexible_request_graph.rb', line 15 def preplexed @preplexed end |
#source_assets_qc_metrics ⇒ Object (readonly)
Returns the value of attribute source_assets_qc_metrics.
15 16 17 |
# File 'app/models/submission/flexible_request_graph.rb', line 15 def source_assets_qc_metrics @source_assets_qc_metrics end |
Instance Method Details
#build! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/submission/flexible_request_graph.rb', line 31 def build! raise RequestChainError, 'Request chains can only be built once' if built? raise StandardError, 'No request types specified!' if request_types.empty? request_types.inject(source_assets_qc_metrics) do |source_assets_qc_metrics_memo, request_type| link = ChainLink.build!(request_type, multiplier_for(request_type), source_assets_qc_metrics_memo, self) break if preplexed && link.multiplexed? link.target_assets_qc_metrics end @built = true end |
#multiplexing_assets ⇒ Object
multiplexing_assets returns @multiplexing_assets if present otherwise it yields to any presented block and assumes it returns the multiplexing_assets
48 49 50 51 52 53 |
# File 'app/models/submission/flexible_request_graph.rb', line 48 def multiplexing_assets @multiplexed = true @multiplexing_assets ||= yield if block_given? @multiplexing_assets end |