class Pricesphere::Product

Public Instance Methods

with_attributes(attributes = {}) click to toggle source
# File lib/pricesphere/product.rb, line 8
def with_attributes(attributes = {})
  return {} if attributes == {}
  page = 1
  last_page = false
  Enumerator.new do |yielder|
    loop do
      raise StopIteration if last_page
      result = get(attributes.merge({:page => page}))

      if page == result['meta']['pages'].to_i
        last_page = true
      end
      page += 1
      result['products'].each do |product|
        yielder.yield product
      end
    end

  end
end

Private Instance Methods

get(params) click to toggle source
Calls superclass method Pricesphere::Base#get
# File lib/pricesphere/product.rb, line 31
def get(params)
  super('products', params)
end