Sha256: 6f294fe6a22ebfd71c7d210718427680ff24bd98ed6c0b9616e5304c4b491ac2
Contents?: true
Size: 1.01 KB
Versions: 8
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Azeroth class RequestHandler # @api private # # hadler for requests to create resources class Create < RequestHandler private # @private # # Creates and return an instance of the model # # creation uses the method +"#{model.name}_params"+ to # fetch all allowed attributes for creation # # @return [Object] def resource @resource ||= build_resource end # build resource for create # # @return [Object] def build_resource attributes = controller.send("#{model.name}_params") collection = controller.send(model.plural) collection.create(attributes) end # @private # # Response status # # For success, returns +:created+, for # validation errors, it returns +:unprocessable_entity+ # # @return [Symbol] def status resource.valid? ? :created : :unprocessable_entity end end end end
Version data entries
8 entries across 8 versions & 1 rubygems