Module: ActiveRemote::Persistence::ClassMethods
- Defined in:
- lib/active_remote/persistence.rb
Overview
Class methods
Instance Method Summary collapse
-
#create(attributes) ⇒ Object
Creates a remote record through the service.
-
#create!(attributes) ⇒ Object
Creates a remote record through the service and if successful, returns the newly created record.
-
#readonly! ⇒ Object
Mark the class as readonly.
-
#readonly? ⇒ Boolean
Returns true if the class is marked as readonly; otherwise, returns false.
Instance Method Details
#create(attributes) ⇒ Object
Creates a remote record through the service.
The service will run any validations and if any of them fail, will return the record error messages indicating what went wrong.
The newly created record is returned if it was successfully saved or not.
36 37 38 39 40 |
# File 'lib/active_remote/persistence.rb', line 36 def create(attributes) remote = self.new(attributes) remote.save remote end |
#create!(attributes) ⇒ Object
Creates a remote record through the service and if successful, returns the newly created record.
The service will run any validations and if any of them fail, will raise an ActiveRemote::RemoteRecordNotSaved exception.
48 49 50 51 52 |
# File 'lib/active_remote/persistence.rb', line 48 def create!(attributes) remote = self.new(attributes) remote.save! remote end |
#readonly! ⇒ Object
Mark the class as readonly. Overrides instance-level readonly, making any instance of this class readonly.
56 57 58 |
# File 'lib/active_remote/persistence.rb', line 56 def readonly! @readonly = true end |
#readonly? ⇒ Boolean
Returns true if the class is marked as readonly; otherwise, returns false.
61 62 63 |
# File 'lib/active_remote/persistence.rb', line 61 def readonly? @readonly end |