module Postmates::Response
Public Class Methods
build(body)
click to toggle source
# File lib/postmates/response.rb, line 10 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