Sha256: 241a1bc60f164cd1fb431ee08d1a569e26194bef8e82e38e5ea4507b01ed10fd

Contents?: true

Size: 334 Bytes

Versions: 11

Compression:

Stored size: 334 Bytes

Contents

require 'grape_entity'

module Grape::App::Helpers::RespondWith
  class Errors < Grape::Entity
    expose :errors
  end

  # @param [ActiveRecord::Base] record validated record
  def respond_with(record, opts = {})
    unless record.errors.empty?
      opts[:with] = Errors
      status 400
    end
    present record, opts
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
grape-app-0.11.3 lib/grape/app/helpers/respond_with.rb
grape-app-0.11.2 lib/grape/app/helpers/respond_with.rb
grape-app-0.11.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.11.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.10.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.10.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.9.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.8 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.7 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.6 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.5 lib/grape/app/helpers/respond_with.rb