module RestfulResource::RailsValidations::ClassMethods
Public Instance Methods
Source
# File lib/restful_resource/rails_validations.rb, line 20 def delete(id, **) with_validations { super } end
Calls superclass method
Source
# File lib/restful_resource/rails_validations.rb, line 16 def get(**) with_validations { super } end
Calls superclass method
Source
# File lib/restful_resource/rails_validations.rb, line 8 def patch(id, data: {}, **others) with_validations(id, data: data) { super } end
Calls superclass method
Source
# File lib/restful_resource/rails_validations.rb, line 12 def post(data: {}, **) with_validations(data: data) { super } end
Calls superclass method
Source
# File lib/restful_resource/rails_validations.rb, line 4 def put(id, data: {}, **others) with_validations(id, data: data) { super } end
Calls superclass method
Private Instance Methods
Source
# File lib/restful_resource/rails_validations.rb, line 26 def with_validations(id = nil, data: {}) yield rescue HttpClient::UnprocessableEntity => e errors = parse_json(e.response.body) result = if errors.is_a?(Hash) && errors.key?('errors') data.merge(errors) else data.merge(errors: errors) end result = result.merge(id: id) if id new(result) end