def filter(other_query)
      query  = self.query
      fields = query.fields.to_set
      unique = other_query.unique?

      # TODO: push this into a Query#subset? method
      if other_query.links.empty?                 &&
        (unique || (!unique && !query.unique?))   &&
        !other_query.reload?                      &&
        !other_query.raw?                         &&
        other_query.fields.to_set.subset?(fields) &&
        other_query.condition_properties.subset?(fields)
      then
        other_query.filter_records(to_a.dup)
      end
    end
def filter(other_query)
      query  = self.query
      fields = query.fields.to_set
      unique = other_query.unique?

      # TODO: push this into a Query#subset? method
      if other_query.links.empty?                 &&
        (unique || (!unique && !query.unique?))   &&
        !other_query.reload?                      &&
        !other_query.raw?                         &&
        other_query.fields.to_set.subset?(fields) &&
        other_query.condition_properties.subset?(fields)
      then
        other_query.filter_records(to_a.dup)
      end
    end
Filter resources in the collection based on a Query

 @param [Query] query
   the query to match each resource in the collection

 @return [Array]
   the resources that match the Query
 @return [nil]
   nil if no resources match the Query

 @api private