module Acfs::Resource::Persistence::ClassMethods
Public Instance Methods
@api public
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.
@param data [Hash{Symbol, String => Object}]
Data to send in create request.
@return [self] Newly resource object.
@raise [Acfs::ErroneousResponse]
If remote service respond with not successful response.
@see Acfs::Model::Persistence#save! Available options. ‘:data`
will be overridden with provided data hash.
@see create!
# File lib/acfs/resource/persistence.rb, line 240 def create(data, _opts = {}) model = new data model.save model end
@api public
Create a new resource sending given data. If resource cannot be created an error will be thrown.
Saving a resource is a synchronous operation.
@param data [Hash{Symbol, String => Object}]
Data to send in create request.
@return [self] Newly resource object.
@raise [Acfs::InvalidResource]
If remote services respond with 422 response. Will fill errors with data from response
@raise [Acfs::ErroneousResponse]
If remote service respond with not successful response.
@see Acfs::Model::Persistence#save! Available options. ‘:data`
will be overridden with provided data hash.
@see create
# File lib/acfs/resource/persistence.rb, line 216 def create!(data, _opts = {}) new(data).tap(&:save!) end