Class: Dugway::Drops::ProductDrop
- Inherits:
-
BaseDrop
- Object
- Liquid::Drop
- BaseDrop
- Dugway::Drops::ProductDrop
show all
- Defined in:
- lib/dugway/liquid/drops/product_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
#artists ⇒ Object
84
85
86
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 84
def artists
@artists ||= source['artists'].map { |a| ArtistDrop.new(a) } rescue []
end
|
#categories ⇒ Object
80
81
82
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 80
def categories
@categories ||= source['categories'].map { |c| CategoryDrop.new(c) } rescue []
end
|
#created_at ⇒ Object
4
5
6
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 4
def created_at
Time.parse(source['created_at'])
end
|
#css_class ⇒ Object
88
89
90
91
92
93
94
95
96
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 88
def css_class
@css_class ||= begin
c = 'product'
c += ' sold' if status == 'sold-out'
c += ' soon' if status == 'coming-soon'
c += ' sale' if on_sale
c
end
end
|
#edit_url ⇒ Object
76
77
78
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 76
def edit_url
'http://bigcartel.com'
end
|
#has_default_option ⇒ Object
24
25
26
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 24
def has_default_option
@has_default_option ||= options.size == 1 && option.name.downcase == 'default'
end
|
#image ⇒ Object
44
45
46
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 44
def image
@image ||= images.blank? ? nil : images.first
end
|
#image_count ⇒ Object
52
53
54
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 52
def image_count
@image_count ||= images.size
end
|
#images ⇒ Object
48
49
50
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 48
def images
@images ||= source['images'].present? ? source['images'].map { |image| ImageDrop.new(image) } : []
end
|
#max_price ⇒ Object
16
17
18
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 16
def max_price
@max_price ||= price_min_max.last
end
|
#min_price ⇒ Object
12
13
14
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 12
def min_price
@min_price ||= price_min_max.first
end
|
#next_product ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 66
def next_product
@next_product ||= begin
if next_product = store.next_product(permalink)
ProductDrop.new(next_product)
else
nil
end
end
end
|
#option ⇒ Object
28
29
30
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 28
def option
@option ||= options.blank? ? nil : options.first
end
|
#options ⇒ Object
32
33
34
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 32
def options
@options ||= source['options'].each_with_index.map { |o,i| ProductOptionDrop.new(o.update('position' => i+1, 'product' => self)) }
end
|
#options_in_stock ⇒ Object
36
37
38
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 36
def options_in_stock
@options_in_stock ||= options.reject { |o| o.sold_out }
end
|
#previous_product ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 56
def previous_product
@previous_product ||= begin
if previous_product = store.previous_product(permalink)
ProductDrop.new(previous_product)
else
nil
end
end
end
|
#price ⇒ Object
8
9
10
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 8
def price
nil end
|
#shipping ⇒ Object
40
41
42
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 40
def shipping
@shipping ||= source['shipping'].present? ? source['shipping'].map { |o| ShippingOptionDrop.new(o.update('product' => self)) } : []
end
|
#variable_pricing ⇒ Object
20
21
22
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 20
def variable_pricing
@variable_pricing ||= min_price != max_price
end
|