Class: Dugway::Drops::ThemeDrop
- Defined in:
- lib/dugway/liquid/drops/theme_drop.rb
Instance Attribute Summary
Attributes inherited from BaseDrop
Instance Method Summary collapse
- #before_method(method_or_key) ⇒ Object
- #features ⇒ Object
- #image_sets ⇒ Object
-
#images ⇒ Object
Newer API for theme images.
-
#initialize(customization, definitions = {}) ⇒ ThemeDrop
constructor
A new instance of ThemeDrop.
-
#translations ⇒ Object
Provides access to theme translations via theme.translations.
Methods inherited from BaseDrop
#cart, #context=, #error, #errors, #method_missing, #store, #theme
Constructor Details
#initialize(customization, definitions = {}) ⇒ ThemeDrop
Returns a new instance of ThemeDrop.
6 7 8 9 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 6 def initialize(customization, definitions = {}) super(customization) @definitions = definitions || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dugway::Drops::BaseDrop
Instance Method Details
#before_method(method_or_key) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 11 def before_method(method_or_key) # We should try to get away from this api and use the newer one below if source.respond_to?('has_key?') && source.has_key?(method_or_key) && settings_images.find { |image| image['variable'] == method_or_key.to_s } return ImageDrop.new(source[method_or_key].stringify_keys) end super end |
#features ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 30 def features # Fetch features config from the top-level Dugway options hash, # which should contain the parsed store configuration (e.g., dugway.json). # This allows 'features' to be a peer to 'store' and 'customization'. feature_data = Dugway.&.fetch('features', {}) || {} Drops::FeaturesDrop.new(feature_data) end |
#image_sets ⇒ Object
26 27 28 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 26 def image_sets Drops::ThemeImageSetsDrop.new(source) end |
#images ⇒ Object
Newer API for theme images. theme.images.logo
22 23 24 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 22 def images Drops::ThemeImagesDrop.new(source) end |
#translations ⇒ Object
Provides access to theme translations via theme.translations
39 40 41 42 43 44 |
# File 'lib/dugway/liquid/drops/theme_drop.rb', line 39 def translations # Instantiate and return the TranslationsDrop, passing settings. # Memoize the instance for efficiency within a single render cycle. # Pass both customization (source) and definitions to TranslationsDrop. @translations_drop ||= Drops::TranslationsDrop.new(source, @definitions) end |