Class: Dugway::Drops::BaseDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Dugway::Drops::BaseDrop
- Defined in:
- lib/dugway/liquid/drops/base_drop.rb
Direct Known Subclasses
AccountDrop, ArtistDrop, ArtistsDrop, CartDrop, CartItemDrop, CategoriesDrop, CategoryDrop, ContactDrop, CountryDrop, CurrencyDrop, FeaturesDrop, ImageDrop, OptionGroupDrop, OptionGroupValueDrop, PageDrop, PagesDrop, ProductDrop, ProductOptionDrop, ProductsDrop, RelatedProductsDrop, ShippingOptionDrop, ThemeDrop, ThemeImageSetsDrop, ThemeImagesDrop, TranslationsDrop
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #before_method(method_or_key) ⇒ Object
- #cart ⇒ Object
- #context=(current_context) ⇒ Object
- #error(msg) ⇒ Object
- #errors ⇒ Object
-
#initialize(source = nil) ⇒ BaseDrop
constructor
A new instance of BaseDrop.
- #method_missing(method, *args, &block) ⇒ Object
- #store ⇒ Object
- #theme ⇒ Object
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 (readonly)
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 (readonly)
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 (readonly)
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) # don't do anything, just let it default here 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 |