Class: Katello::PoolWithQuantities
- Inherits:
-
Object
- Object
- Katello::PoolWithQuantities
- Defined in:
- app/models/katello/pool_with_quantities.rb
Instance Attribute Summary collapse
-
#pool ⇒ Object
Returns the value of attribute pool.
-
#quantities ⇒ Object
Returns the value of attribute quantities.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pool = nil, quantities = []) ⇒ PoolWithQuantities
constructor
A new instance of PoolWithQuantities.
- #to_hash ⇒ Object
Constructor Details
#initialize(pool = nil, quantities = []) ⇒ PoolWithQuantities
Returns a new instance of PoolWithQuantities.
5 6 7 8 9 |
# File 'app/models/katello/pool_with_quantities.rb', line 5 def initialize(pool = nil, quantities = []) @pool = pool @quantities = quantities @quantities = [@quantities] if !@quantities.nil? && !@quantities.is_a?(Array) end |
Instance Attribute Details
#pool ⇒ Object
Returns the value of attribute pool.
3 4 5 |
# File 'app/models/katello/pool_with_quantities.rb', line 3 def pool @pool end |
#quantities ⇒ Object
Returns the value of attribute quantities.
3 4 5 |
# File 'app/models/katello/pool_with_quantities.rb', line 3 def quantities @quantities end |
Class Method Details
.fetch(params) ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/models/katello/pool_with_quantities.rb', line 15 def self.fetch(params) if params.is_a?(PoolWithQuantities) params else PoolWithQuantities.new(Pool.find(params["pool_id"]), params["quantities"]) end end |
Instance Method Details
#to_hash ⇒ Object
11 12 13 |
# File 'app/models/katello/pool_with_quantities.rb', line 11 def to_hash {"pool_id" => pool.id, "quantities" => quantities.as_json} end |