Sha256: 4ed6d0dfd2a1dde4858f47a84f548a65d405289dd835a47db0dec4844770231f
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
module RemoteResource module Builder extend ActiveSupport::Concern module ClassMethods def build_resource_from_response(response) build_resource response.sanitized_response_body, response_hash(response) end def build_resource(collection, response_hash = {}) if collection.is_a? Hash new collection.merge response_hash end end def build_collection_from_response(response) build_collection response.sanitized_response_body, response_hash(response) end def build_collection(collection, response_hash = {}) if collection.is_a? Array RemoteResource::Collection.new self, collection, response_hash end end private def response_hash(response_object) { _response: response_object } end end def rebuild_resource_from_response(response) rebuild_resource response.sanitized_response_body, response_hash(response) end def rebuild_resource(collection, response_hash = {}) if collection.is_a? Hash self.attributes = collection.merge(response_hash) else self.attributes = response_hash end and self end private def response_hash(response_object) self.class.send :response_hash, response_object end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ddy_remote_resource-0.4.4 | lib/remote_resource/builder.rb |
ddy_remote_resource-0.4.3 | lib/remote_resource/builder.rb |
ddy_remote_resource-0.4.2 | lib/remote_resource/builder.rb |