Sha256: dcac5fb730277f809cd39acc3ca104267bd9bfcccd14052aff92997b69e8f337
Contents?: true
Size: 835 Bytes
Versions: 1
Compression:
Stored size: 835 Bytes
Contents
module Spree module API module Query def collection_query(collection_name, object_class, uri, &block) if block_given? BW::HTTP.get(uri) do |response| json = BW::JSON.parse(response.body.to_str) collection = (json[collection_name] || []).map do |object_json| object_class.new(object_json) end block.call collection end else BW::HTTP.get(uri) end end def object_query(object_class, uri, &block) if block_given? BW::HTTP.get(uri) do |response| json = BW::JSON.parse(response.body.to_str) object = object_class.new(json) block.call object end else BW::HTTP.get(uri) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree-wrap-0.0.2 | motion/spree/api/query.rb |