module ObjectJSONMapper::Persistence::ClassMethods
Public Instance Methods
create(params = {})
click to toggle source
@param params [Hash] @return [ObjectJSONMapper::Base] current model instance
# File lib/object_json_mapper/persistence.rb, line 75 def create(params = {}) response = client.post(params) result = if response.headers[:location] RestClient.get(response.headers[:location], ObjectJSONMapper.headers) else response.body end persist(HTTP.parse_json(result)) rescue RestClient::ExceptionWithResponse => e raise e unless e.response.code == 422 new.tap do |base| base.load_errors(HTTP.parse_json(e.response.body)) end end