Class: MultiPool
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MultiPool
- Includes:
- Pipelineable
- Defined in:
- app/models/multi_pool.rb
Overview
MultiPool A collection of pools grouped/created together using a specific pooling method.
Instance Method Summary collapse
-
#consistent_pools_type? ⇒ void
Checks that all pools in the multi pool are of the same type.
-
#number_of_pools ⇒ Integer
Returns the number of pools in the multi pool.
-
#unique_pool_positions? ⇒ void
Checks that all pools in the multi pool have unique positions.
Methods included from Pipelineable
Instance Method Details
#consistent_pools_type? ⇒ void
This method returns an undefined value.
Checks that all pools in the multi pool are of the same type.
22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/multi_pool.rb', line 22 def consistent_pools_type? return true if multi_pool_positions.empty? types = multi_pool_positions.map(&:pipeline).compact.uniq return true if types.size <= 1 errors.add(:multi_pool_positions, 'all pools must be of the same type') false end |
#number_of_pools ⇒ Integer
Returns the number of pools in the multi pool.
48 49 50 |
# File 'app/models/multi_pool.rb', line 48 def number_of_pools multi_pool_positions.length end |
#unique_pool_positions? ⇒ void
This method returns an undefined value.
Checks that all pools in the multi pool have unique positions.
35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/multi_pool.rb', line 35 def unique_pool_positions? positions = multi_pool_positions.map(&:position) duplicate_positions = positions.select { |pos| positions.count(pos) > 1 } return true unless duplicate_positions.any? errors.add(:multi_pool_positions, "#{duplicate_positions.uniq.join(', ')} positions are duplicated") false end |