class Dugway::Drops::ProductDrop

Public Instance Methods

artists() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 93
def artists
  @artists ||= source['artists'].map { |a| ArtistDrop.new(a) } rescue []
end
categories() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 89
def categories
  @categories ||= source['categories'].map { |c| CategoryDrop.new(c) } rescue []
end
created_at() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 4
def created_at
  Time.parse(source['created_at'])
end
css_class() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 97
def css_class
  @css_class ||= begin
    c = 'product'
    c += ' sold' if status == 'sold-out'
    c += ' soon' if status == 'coming-soon'
    c += ' sale' if on_sale
    c
  end
end
edit_url() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 85
def edit_url
  'http://bigcartel.com'
end
has_default_option() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 24
def has_default_option
  @has_default_option ||= options.size == 1 && option.name.downcase == 'default'
end
has_option_groups() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 40
def has_option_groups
  source['has_option_groups']
end
image() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 53
def image
  @image ||= images.blank? ? nil : images.first
end
image_count() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 61
def image_count
  @image_count ||= images.size
end
images() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 57
def images
  @images ||= source['images'].present? ? source['images'].map { |image| ImageDrop.new(image) } : []
end
max_price() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 16
def max_price
  @max_price ||= price_min_max.last
end
min_price() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 12
def min_price
  @min_price ||= price_min_max.first
end
next_product() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 75
def next_product
  @next_product ||= begin
    if next_product = store.next_product(permalink)
      ProductDrop.new(next_product)
    else
      nil
    end
  end
end
option() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 28
def option
  @option ||= options.blank? ? nil : options.first
end
option_groups() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 44
def option_groups
  @option_groups ||= source['option_groups'].present? ?
    source['option_groups'].map { |group| OptionGroupDrop.new(group) } : []
end
options() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 32
def options
  @options ||= source['options'].each_with_index.map { |o,i| ProductOptionDrop.new(o.update('position' => i+1, 'product' => self)) }
end
options_in_stock() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 36
def options_in_stock
  @options_in_stock ||= options.reject { |o| o.sold_out }
end
previous_product() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 65
def previous_product
  @previous_product ||= begin
    if previous_product = store.previous_product(permalink)
      ProductDrop.new(previous_product)
    else
      nil
    end
  end
end
price() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 8
def price
  nil # price is deprecated in favor of default_price
end
shipping() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 49
def shipping
  @shipping ||= source['shipping'].present? ? source['shipping'].map { |o| ShippingOptionDrop.new(o.update('product' => self)) } : []
end
variable_pricing() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 20
def variable_pricing
  @variable_pricing ||= min_price != max_price
end

Private Instance Methods

price_min_max() click to toggle source
# File lib/dugway/liquid/drops/product_drop.rb, line 109
def price_min_max
  @price_min_max ||= options.collect(&:price).uniq.minmax
end