Sha256: fc65c4f6664a0754cec3be1f0efe4c5d41e5ab6f41219e0a2fe43c6a62fea1e8

Contents?: true

Size: 729 Bytes

Versions: 15

Compression:

Stored size: 729 Bytes

Contents

module Dugway
  module Drops
    class ProductOptionDrop < BaseDrop
      def default
        position == 1
      end

      def has_custom_price
        price != product.default_price
      end

      # Make up inventory numbers since we obviously don't want that from the API

      def quantity
        @quantity ||= sold_out ? 0 : rand(100)
      end

      def sold
        @sold ||= rand(100)
      end

      def inventory
        ((quantity.to_f / (quantity + sold).to_f) * 100).round
      end

      def option_group_values
        @option_group_values ||= source['option_group_values'].present? ?
          source['option_group_values'].map { |value| OptionGroupValueDrop.new(value) } : []
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dugway-1.0.10 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.9 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.8 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.7 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.6 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.5 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.4 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.3 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.2 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.1 lib/dugway/liquid/drops/product_option_drop.rb
dugway-1.0.0 lib/dugway/liquid/drops/product_option_drop.rb
dugway-0.12.3 lib/dugway/liquid/drops/product_option_drop.rb
dugway-0.12.2 lib/dugway/liquid/drops/product_option_drop.rb
dugway-0.12.1 lib/dugway/liquid/drops/product_option_drop.rb
dugway-0.12.0 lib/dugway/liquid/drops/product_option_drop.rb