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
#as_json, #before_method, #cart, #context=, #error, #errors, #initialize, #liquid_method_missing, #method_missing, #store, #theme, #to_liquid
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Dugway::Drops::BaseDrop
Instance Method Details
#artists ⇒ Object
102
103
104
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 102
def artists
@artists ||= (source['artists'] || []).map { |a| ArtistDrop.new(a) }
end
|
#categories ⇒ Object
98
99
100
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 98
def categories
@categories ||= (source['categories'] || []).map { |c| CategoryDrop.new(c) }
end
|
#created_at ⇒ Object
9
10
11
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 9
def created_at
Time.parse(source['created_at'])
end
|
#css_class ⇒ Object
106
107
108
109
110
111
112
113
114
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 106
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
94
95
96
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 94
def edit_url
'http://bigcartel.com'
end
|
#has_default_option ⇒ Object
29
30
31
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 29
def has_default_option
@has_default_option ||= options.size == 1 && option.name.downcase == 'default'
end
|
#has_option_groups ⇒ Object
45
46
47
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 45
def has_option_groups
source['has_option_groups']
end
|
#has_password_protection ⇒ Object
49
50
51
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 49
def has_password_protection
source && source['has_password_protection']
end
|
#image ⇒ Object
62
63
64
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 62
def image
@image ||= images.blank? ? nil : images.first
end
|
#image_count ⇒ Object
70
71
72
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 70
def image_count
@image_count ||= images.size
end
|
#images ⇒ Object
66
67
68
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 66
def images
@images ||= source['images'].present? ? source['images'].map { |image| ImageDrop.new(image) } : []
end
|
#max_price ⇒ Object
21
22
23
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 21
def max_price
@max_price ||= price_min_max.last
end
|
#min_price ⇒ Object
17
18
19
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 17
def min_price
@min_price ||= price_min_max.first
end
|
#next_product ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 84
def next_product
@next_product ||= begin
if next_product = store.next_product(permalink)
ProductDrop.new(next_product)
else
nil
end
end
end
|
#option ⇒ Object
33
34
35
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 33
def option
@option ||= options.blank? ? nil : options.first
end
|
#option_groups ⇒ Object
53
54
55
56
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 53
def option_groups
@option_groups ||= source['option_groups'].present? ?
source['option_groups'].map { |group| OptionGroupDrop.new(group) } : []
end
|
#options ⇒ Object
37
38
39
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 37
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
41
42
43
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 41
def options_in_stock
@options_in_stock ||= options.reject { |o| o.sold_out }
end
|
#previous_product ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 74
def previous_product
@previous_product ||= begin
if previous_product = store.previous_product(permalink)
ProductDrop.new(previous_product)
else
nil
end
end
end
|
#price ⇒ Object
13
14
15
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 13
def price
nil
end
|
#price_suffix ⇒ Object
Used to simulate price suffix behavior In prod this is a per-product setting but for dugway it needs to be global
126
127
128
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 126
def price_suffix
store.price_suffix
end
|
116
117
118
119
120
121
122
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 116
def related_products
@related_products ||= begin
drop = RelatedProductsDrop.new(source)
drop.context = @context if @context
drop.products
end
end
|
#shipping ⇒ Object
58
59
60
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 58
def shipping
@shipping ||= source['shipping'].present? ? source['shipping'].map { |o| ShippingOptionDrop.new(o.update('product' => self)) } : []
end
|
#to_s ⇒ Object
Liquid 5.x compatibility: ensure proper string representation
6
7
8
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 6
def to_s
name || "Product ##{id}"
end
|
#variable_pricing ⇒ Object
25
26
27
|
# File 'lib/dugway/liquid/drops/product_drop.rb', line 25
def variable_pricing
@variable_pricing ||= min_price != max_price
end
|