Sha256: caa2eb90fc4a93f99404631bd57253da8f64c086de8ca805dfe641a785f84c2e

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module DeviseTokenAuth
  class ResourceErrorsSerializer
    def initialize(*args)
      @args = args
    end

    attr_reader :args

    def as_json(options)
      resource = args[0]
      response = {
        status: "error",
        data: resource.as_json(except: [:tokens, :created_at, :updated_at])
      }
      if args.length > 1
        args.shift
        response[:errors] = args
      else
        response[:errors] = resource.errors.to_hash.merge(full_messages: resource.errors.full_messages)
      end
      response
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xing_backend_token_auth-0.1.32 app/serializers/devise_token_auth/resource_errors_serializer.rb
xing_backend_token_auth-0.1.31 app/serializers/devise_token_auth/resource_errors_serializer.rb