Class: Dugway::Drops::BaseDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Dugway::Drops::BaseDrop
show all
- Defined in:
- lib/dugway/liquid/drops/base_drop.rb
Direct Known Subclasses
AccountDrop, ArtistDrop, ArtistsDrop, CartDrop, CartItemDrop, CategoriesDrop, CategoryDrop, ContactDrop, CountryDrop, CurrencyDrop, ImageDrop, PageDrop, PagesDrop, ProductDrop, ProductOptionDrop, ProductsDrop, ShippingOptionDrop, ThemeDrop
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source = nil) ⇒ BaseDrop
Returns a new instance of BaseDrop.
8
9
10
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 8
def initialize(source=nil)
@source = source
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
46
47
48
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 46
def method_missing(method, *args, &block)
before_method(method.to_s)
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
6
7
8
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 6
def params
@params
end
|
#request ⇒ Object
Returns the value of attribute request.
5
6
7
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 5
def request
@request
end
|
#source ⇒ Object
Returns the value of attribute source.
4
5
6
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 4
def source
@source
end
|
Instance Method Details
#before_method(method_or_key) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 30
def before_method(method_or_key)
if respond_to?(method_or_key)
elsif source.respond_to?(method_or_key)
return source.send(method_or_key)
elsif source.respond_to?('has_key?') && source.has_key?(method_or_key)
return source[method_or_key]
elsif source.is_a?(Array) && source.first.has_key?('permalink')
for item in source
return item if item['permalink'] == method_or_key.to_s
end
end
nil
end
|
#cart ⇒ Object
26
27
28
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 26
def cart
Dugway.cart
end
|
#context=(current_context) ⇒ Object
12
13
14
15
16
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 12
def context=(current_context)
@request = current_context.registers[:request]
@params = current_context.registers[:params]
super
end
|
#error(msg) ⇒ Object
54
55
56
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 54
def error(msg)
errors << msg
end
|
#errors ⇒ Object
50
51
52
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 50
def errors
@context['errors']
end
|
#store ⇒ Object
18
19
20
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 18
def store
Dugway.store
end
|
#theme ⇒ Object
22
23
24
|
# File 'lib/dugway/liquid/drops/base_drop.rb', line 22
def theme
Dugway.theme
end
|