Module: RemoteResource::Querying::PersistenceMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/remote_resource/querying/persistence_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #destroy(connection_options = {}) ⇒ Object
- #save(connection_options = {}) ⇒ Object
- #update_attributes(attributes = {}, connection_options = {}) ⇒ Object
Instance Method Details
#destroy(connection_options = {}) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/remote_resource/querying/persistence_methods.rb', line 34 def destroy( = {}) id.present? || raise(RemoteResource::IdMissingError.new("`id` is missing from resource")) response = RemoteResource::Request.new(self, :delete, {}, .merge(id: id)).perform handle_response(response) self.destroyed = success? success? ? self : false end |
#save(connection_options = {}) ⇒ Object
29 30 31 32 |
# File 'lib/remote_resource/querying/persistence_methods.rb', line 29 def save( = {}) create_or_update(self.attributes, ) success? ? self : false end |
#update_attributes(attributes = {}, connection_options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/remote_resource/querying/persistence_methods.rb', line 23 def update_attributes(attributes = {}, = {}) rebuild_resource(attributes) create_or_update(attributes.reverse_merge(id: id), ) success? ? self : false end |