lib/quirky-api/serializers/quirky_serializer.rb
def filter_attributes(attrs)
    attributes = attrs.each_with_object({}) do |name, inst|
      next unless validates?(name)
      inst[name] = get_field(name)
    end

    optional_fields = _optional
    if optional_fields.present?
      optional_fields.each do |field|
        next unless validates?(field)
        attributes[field] = get_field(field)
      end
    end

    associated_fields = _associations
    if associated_fields.present?
      associated_fields.each do |assoc|
        next unless validates?(assoc)
        attributes[assoc] = get_association(assoc)
      end
    end

    attributes
  end
# Filters attributes and returns their values.
#
# @param attrs [Array] All of the attributes we need values for.
# @return [Hash] A hash of key / value pairs.
Filters attributes and returns their values.
Filters attributes and returns their values .
def filter_attributes(attrs)
    attributes = attrs.each_with_object({}) do |name, inst|
      next unless validates?(name)
      inst[name] = get_field(name)
    end
    optional_fields = _optional
    if optional_fields.present?
      optional_fields.each do |field|
        next unless validates?(field)
        attributes[field] = get_field(field)
      end
    end
    associated_fields = _associations
    if associated_fields.present?
      associated_fields.each do |assoc|
        next unless validates?(assoc)
        attributes[assoc] = get_association(assoc)
      end
    end
    attributes
  end
def filter_attributes ( attrs ) attributes = attrs . each_with_object ( { } ) do | name , inst | next unless validates? ( name ) inst [ name ] = get_field ( name ) end optional_fields = _optional if optional_fields . present? optional_fields . each do | field | next unless validates? ( field ) attributes [ field ] = get_field ( field ) end end associated_fields = _associations if associated_fields . present? associated_fields . each do | assoc | next unless validates? ( assoc ) attributes [ assoc ] = get_association ( assoc ) end end attributes end
Filters attributes and returns their values.
Filters attributes and returns their values .
A hash of key / value pairs.
A hash of key / value pairs .
Hash
attrs
All of the attributes we need values for.
All of the attributes we need values for .