lib/quirky-api/serializers/quirky_serializer.rb
def warnings(params)
      # Ignore unless warn_invalid_fields is set.
      return unless QuirkyApi.warn_invalid_fields

      # Basic information about the request.
      params = params.symbolize_keys
      req_fields = [*params[:extra_fields]].map(&:to_sym)
      klass_fields = [*_optional_fields]

      good_fields = klass_fields & req_fields
      bad_fields = (req_fields - klass_fields)

      # Find any invalid fields and add a message.
      bad = bad_fields.reduce([]) do |w, f|
        w << "The '#{f}' field is not a valid optional field"
      end if good_fields.blank? || good_fields.length != req_fields.length

      # Return the warnings.
      bad
    end
# Returns warnings about your request. Warnings are messages that alert
# you to things that are wrong, but not breaking.  In this initial release,
# warnings are only triggered by requesting optional fields that do not
# exist in the serializer.
#
# Warnings will be returned as an array at the end of the payload with the
# key 'warnings'.
#
# Warnings must be enabled through the +warn_invalid_fields+ configuration
# option.
#
# @param params [Hashie] The params object that is passed around in Rails.
#
# @return [Array] An array of warnings.
#
# @example
#   # GET /api/v1/users/1?extra_fields[]=asdfg
#
#   {
#     "data": {
#       ...
#     },
#     "warnings": [
#       "The optional field 'asdfg' does not exist."
#     ]
#   }
#
# @see QuirkyApi.configure
Returns warnings about your request. Warnings are messages that alert
you to things that are wrong, but not breaking.  In this initial release,
warnings are only triggered by requesting optional fields that do not
exist in the serializer.

Warnings will be returned as an array at the end of the payload with the
key 'warnings'.

Warnings must be enabled through the +warn_invalid_fields+ configuration
option.
Returns warnings about your request . Warnings are messages that alert you to things that are wrong but not breaking . In this initial release warnings are only triggered by requesting optional fields that do not exist in the serializer . Warnings will be returned as an array at the end of the payload with the key ' warnings ' . Warnings must be enabled through the + warn_invalid_fields + configuration option .
def warnings(params)
      return unless QuirkyApi.warn_invalid_fields
      params = params.symbolize_keys
      req_fields = [*params[:extra_fields]].map(&:to_sym)
      klass_fields = [*_optional_fields]
      good_fields = klass_fields & req_fields
      bad_fields = (req_fields - klass_fields)
      bad = bad_fields.reduce([]) do |w, f|
        w << "The '#{f}' field is not a valid optional field"
      end if good_fields.blank? || good_fields.length != req_fields.length
      bad
    end
def warnings ( params ) return unless QuirkyApi . warn_invalid_fields params = params . symbolize_keys req_fields = [ * params [ :extra_fields ] ] . map ( & :to_sym ) klass_fields = [ * _optional_fields ] good_fields = klass_fields & req_fields bad_fields = ( req_fields - klass_fields ) bad = bad_fields . reduce ( [ ] ) do | w , f | w << "The '#{f}' field is not a valid optional field" end if good_fields . blank? || good_fields . length != req_fields . length bad end
Returns warnings about your request.
Returns warnings about your request .
# Ignore unless warn_invalid_fields is set. # Basic information about the request. # Find any invalid fields and add a message. # Return the warnings.
An array of warnings.
An array of warnings .
Array
params
The params object that is passed around in Rails.
The params object that is passed around in Rails .
example
None
see
None