Class: SpreeCmCommissioner::CachedInventoryItem

Inherits:
Object
  • Object
show all
Defined in:
lib/spree_cm_commissioner/cached_inventory_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CachedInventoryItem

Returns a new instance of CachedInventoryItem.



12
13
14
15
16
17
18
19
20
21
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 12

def initialize(options = {})
  @inventory_key = options[:inventory_key]
  @inventory_hold_key = options[:inventory_hold_key]
  @active = options[:active]
  @quantity_available = options[:quantity_available]
  @quantity_on_hold = options[:quantity_on_hold]
  @max_capacity = options[:max_capacity]
  @inventory_item_id = options[:inventory_item_id]
  @variant_id = options[:variant_id]
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def active
  @active
end

#inventory_hold_keyObject (readonly)

Returns the value of attribute inventory_hold_key.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def inventory_hold_key
  @inventory_hold_key
end

#inventory_item_idObject (readonly)

Returns the value of attribute inventory_item_id.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def inventory_item_id
  @inventory_item_id
end

#inventory_keyObject (readonly)

Returns the value of attribute inventory_key.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def inventory_key
  @inventory_key
end

#max_capacityObject (readonly)

Returns the value of attribute max_capacity.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def max_capacity
  @max_capacity
end

#quantity_availableObject (readonly)

Returns the value of attribute quantity_available.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def quantity_available
  @quantity_available
end

#quantity_on_holdObject (readonly)

Returns the value of attribute quantity_on_hold.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def quantity_on_hold
  @quantity_on_hold
end

#variant_idObject (readonly)

Returns the value of attribute variant_id.



3
4
5
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 3

def variant_id
  @variant_id
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 23

def active?
  active
end

#to_hObject



27
28
29
30
31
# File 'lib/spree_cm_commissioner/cached_inventory_item.rb', line 27

def to_h
  instance_variables.each_with_object({}) do |var, hash|
    hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
  end
end