Sha256: f2a63e53aa54af6c934a3a8ec2f02c4d7096b733421fab6c57331dd4e3f53add

Contents?: true

Size: 336 Bytes

Versions: 20

Compression:

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

20 entries across 20 versions & 1 rubygems

Version Path
grape-app-0.5.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.5.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.4.3 lib/grape/app/helpers/respond_with.rb
grape-app-0.4.2 lib/grape/app/helpers/respond_with.rb
grape-app-0.4.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.4.0 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.17 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.16 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.15 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.14 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.12 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.11 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.10 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.9 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.5 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.4 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.3 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.2 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.1 lib/grape/app/helpers/respond_with.rb
grape-app-0.3.0 lib/grape/app/helpers/respond_with.rb