Class: Workarea::Storefront::ProductViewModel::ImageCollection
- Inherits:
-
Object
- Object
- Workarea::Storefront::ProductViewModel::ImageCollection
show all
- Includes:
- Enumerable
- Defined in:
- app/view_models/workarea/storefront/product_view_model/image_collection.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(product, options = {}, images = nil) ⇒ ImageCollection
Returns a new instance of ImageCollection.
9
10
11
12
13
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 9
def initialize(product, options = {}, images = nil)
@product = product
@options = options.with_indifferent_access
@all = images || @product.images
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
29
30
31
32
33
34
35
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 29
def method_missing(sym, *args, &block)
if @all.respond_to?(sym)
@all.send(sym, *args, &block)
else
super
end
end
|
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
7
8
9
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 7
def all
@all
end
|
Instance Method Details
#+(other) ⇒ Object
21
22
23
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 21
def +(other)
ImageCollection.new(@product, @options, @all + other.all)
end
|
#primary ⇒ Object
15
16
17
18
19
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 15
def primary
@primary ||= selected_facet_images ||
first ||
Catalog::ProductPlaceholderImage.cached
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
25
26
27
|
# File 'app/view_models/workarea/storefront/product_view_model/image_collection.rb', line 25
def respond_to_missing?(method_name, include_private = false)
super || @all.respond_to?(method_name)
end
|