Created
May 7, 2020 17:50
-
-
Save atomgiant/2c160d6dcd913964027116f126ed5cea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Liquid | |
class ProductMock | |
attr_accessor :id, :collections, :variants, :created_at, :tags | |
def initialize(id: 123, collections: [], variants:[], created_at: Date.yesterday, tags:[]) | |
@collections = [] | |
@variants = variants | |
@created_at = created_at | |
@tags = tags | |
end | |
def price_min | |
@variants.map { |e| e.price }.min | |
end | |
def price_max | |
@variants.map { |e| e.price }.max | |
end | |
def to_liquid | |
{ | |
'id' => @id, | |
'collections' => @collections, | |
'variants' => @variants, | |
'created_at' => @created_at, | |
'tags' => @tags, | |
'price_min' => price_min, | |
'price_max' => price_max, | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment