Class: Dugway::Drops::ProductOptionDrop
- Inherits:
-
BaseDrop
- Object
- Liquid::Drop
- BaseDrop
- Dugway::Drops::ProductOptionDrop
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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Dugway::Drops::BaseDrop
Instance Method Details
#default ⇒ Object
4
5
6
|
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 4
def default
position == 1
end
|
#has_custom_price ⇒ Object
8
9
10
|
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 8
def has_custom_price
price != product.default_price
end
|
#inventory ⇒ Object
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
|
#option_group_values ⇒ Object
26
27
28
29
|
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 26
def option_group_values
@option_group_values ||= source['option_group_values'].present? ?
source['option_group_values'].map { |value| OptionGroupValueDrop.new(value) } : []
end
|
#quantity ⇒ Object
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
|
#sold ⇒ Object
18
19
20
|
# File 'lib/dugway/liquid/drops/product_option_drop.rb', line 18
def sold
@sold ||= rand(100)
end
|