Class: Dugway::Drops::ProductOptionDrop

Inherits:
BaseDrop
  • Object
show all
Defined in:
lib/dugway/liquid/drops/product_option_drop.rb

Instance Attribute Summary

Attributes inherited from BaseDrop

#params, #request, #source

Instance Method Summary collapse

Methods inherited from BaseDrop

#before_method, #cart, #context=, #error, #errors, #initialize, #method_missing, #store, #theme

Constructor Details

This class inherits a constructor from Dugway::Drops::BaseDrop

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dugway::Drops::BaseDrop

Instance Method Details

#defaultObject



4
5
6
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 4

def default
  position == 1
end

#has_custom_priceObject



8
9
10
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 8

def has_custom_price
  price != product.default_price
end

#inventoryObject



22
23
24
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 22

def inventory
  ((quantity.to_f / (quantity + sold).to_f) * 100).round
end

#quantityObject

Make up inventory numbers since we obviously don’t want that from the API



14
15
16
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 14

def quantity
  @quantity ||= sold_out ? 0 : rand(100)
end

#soldObject



18
19
20
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 18

def sold
  @sold ||= rand(100)
end