Sha256: 3bb378e0778a7cef527bcf7cf39d19f6e0943d3de4d307052d09802bb9944df4
Contents?: true
Size: 731 Bytes
Versions: 1
Compression:
Stored size: 731 Bytes
Contents
require_relative 'utils' require_relative 'quote' require_relative 'delivery' module Postmates module Response class << self include Postmates::Utils def build(body) kind = body['object'] || body['kind'] case kind when 'list' body['data'].map { |del| Delivery.new(del) }.tap do |list| list.instance_variable_set(:@total_count, body['total_count']) list.instance_variable_set(:@next_href, urlify(body['next_href'])) list.class.module_eval { attr_reader :total_count, :next_href } end when 'delivery' Delivery.new(body) when 'delivery_quote' Quote.new(body) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
postmates-0.1.0 | lib/postmates/response.rb |