Module: RemoteResource::Querying::PersistenceMethods::ClassMethods

Defined in:
lib/remote_resource/querying/persistence_methods.rb

Instance Method Summary collapse

Instance Method Details

#create(attributes = {}, connection_options = {}) ⇒ Object



8
9
10
11
12
# File 'lib/remote_resource/querying/persistence_methods.rb', line 8

def create(attributes = {}, connection_options = {})
  resource = new(attributes)
  response = RemoteResource::Request.new(self, :post, attributes, connection_options).perform
  resource.handle_response(response)
end

#destroy(id, connection_options = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/remote_resource/querying/persistence_methods.rb', line 14

def destroy(id, connection_options = {})
  resource = new(id: id)
  response = RemoteResource::Request.new(self, :delete, {}, connection_options.merge(id: id)).perform
  resource.handle_response(response)
  resource.destroyed = resource.success?
  resource
end