Sha256: 0f61f1c1f98487ac3248dad2b93dba3ab8cc6e9f4192d43ec92e8d95209040ae

Contents?: true

Size: 332 Bytes

Versions: 12

Compression:

Stored size: 332 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

12 entries across 12 versions & 1 rubygems

Version Path
grape-app-0.8.4 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.3 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.2 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.8.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.7.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.6.4 lib/grape/app/helpers/respond_with.rb
grape-app-0.6.3 lib/grape/app/helpers/respond_with.rb
grape-app-0.6.2 lib/grape/app/helpers/respond_with.rb
grape-app-0.6.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.6.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.5.3 lib/grape/app/helpers/respond_with.rb