Class: Katello::PoolWithQuantities

Inherits:
Object
  • Object
show all
Defined in:
app/models/katello/pool_with_quantities.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#poolObject

Returns the value of attribute pool.



3
4
5
# File 'app/models/katello/pool_with_quantities.rb', line 3

def pool
  @pool
end

#quantitiesObject

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_hashObject



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