Sha256: 8058fae53aac6d03a3a09e5f7ed7e0747c9a66b70a57f51a722444e3a516ab58
Contents?: true
Size: 1.16 KB
Versions: 6
Compression:
Stored size: 1.16 KB
Contents
module RemoteResource module Querying module PersistenceMethods extend ActiveSupport::Concern module ClassMethods def create(attributes = {}, connection_options = {}) resource = new attributes response = RemoteResource::Request.new(self, :post, attributes, connection_options).perform resource.handle_response response end end def update_attributes(attributes = {}, connection_options = {}) rebuild_resource attributes attributes.reverse_merge! id: id create_or_update attributes, connection_options success? ? self : false end def save(connection_options = {}) create_or_update self.attributes, connection_options success? ? self : false end def create_or_update(attributes = {}, connection_options = {}) if attributes.has_key? :id response = RemoteResource::Request.new(self, :patch, attributes, connection_options).perform else response = RemoteResource::Request.new(self, :post, attributes, connection_options).perform end handle_response response end end end end
Version data entries
6 entries across 6 versions & 1 rubygems