Module: Acfs::Resource::Persistence::ClassMethods
- Defined in:
- lib/acfs/resource/persistence.rb
Instance Method Summary collapse
-
#create(data, _opts = {}) ⇒ self
Create a new resource sending given data.
-
#create!(data, _opts = {}) ⇒ self
Create a new resource sending given data.
Instance Method Details
#create(data, _opts = {}) ⇒ self
Create a new resource sending given data. If resource cannot be create model will be returned and error hash contains response errors if available.
Saving a resource is a synchronous operation.
240 241 242 243 244 |
# File 'lib/acfs/resource/persistence.rb', line 240 def create(data, _opts = {}) model = new data model.save model end |
#create!(data, _opts = {}) ⇒ self
Create a new resource sending given data. If resource cannot be created an error will be thrown.
Saving a resource is a synchronous operation.
216 217 218 |
# File 'lib/acfs/resource/persistence.rb', line 216 def create!(data, _opts = {}) new(data).tap(&:save!) end |