Sha256: 6ae29ba912ec940fec9589f46d1fb1c616995dbe7cf7e15867678c8fb8ef2ca8
Contents?: true
Size: 1.18 KB
Versions: 7
Compression:
Stored size: 1.18 KB
Contents
module RemoteResource module Builder extend ActiveSupport::Concern module ClassMethods def build_resource_from_response(response) build_resource(response.attributes, { last_request: response.request, last_response: response, meta: response.meta }) end def build_resource(collection, options = {}) if collection.is_a?(Hash) new(collection.merge(options)) end end def build_collection_from_response(response) build_collection(response.attributes, { last_request: response.request, last_response: response, meta: response.meta }) end def build_collection(collection, options = {}) if collection.is_a?(Array) RemoteResource::Collection.new(self, collection, options) end end end def rebuild_resource_from_response(response) rebuild_resource(response.attributes, { last_request: response.request, last_response: response, meta: response.meta }) end def rebuild_resource(collection, options = {}) if collection.is_a?(Hash) self.attributes = collection.merge(options) else self.attributes = options end and self end end end
Version data entries
7 entries across 7 versions & 1 rubygems