class ActiveResponse::Responders::JSON

Public Instance Methods

collection(**opts) click to toggle source
# File lib/active_response/responders/json.rb, line 8
def collection(**opts)
  opts[:json] = opts.delete(:collection)
  controller.render opts
end
destroyed(_opts) click to toggle source
# File lib/active_response/responders/json.rb, line 13
def destroyed(_opts)
  controller.head :no_content, content_type: content_type
end
form(**_opts) click to toggle source
# File lib/active_response/responders/json.rb, line 17
def form(**_opts)
  raise NotImplementedError, 'Forms are not available in JSON'
end
invalid_resource(**opts) click to toggle source
# File lib/active_response/responders/json.rb, line 21
def invalid_resource(**opts)
  opts[:json] = opts.delete(:resource).errors
  opts[:status] ||= :unprocessable_entity
  controller.render opts
end
new_resource(**opts) click to toggle source
# File lib/active_response/responders/json.rb, line 27
def new_resource(**opts)
  opts[:status] = :created
  controller.respond_with_resource(opts)
end
resource(**opts) click to toggle source
# File lib/active_response/responders/json.rb, line 32
def resource(**opts)
  opts[:json] = opts.delete(:resource)
  controller.render opts
end
updated_resource(**opts) click to toggle source
# File lib/active_response/responders/json.rb, line 37
def updated_resource(**opts)
  controller.respond_with_resource(opts)
end