Sha256: c401bef75ed2310ea282de7fee5656f840acf1193a0c4d933f2fe68455dc3681

Contents?: true

Size: 1.6 KB

Versions: 17

Compression:

Stored size: 1.6 KB

Contents

module ActiveRecord
  module Sanitization
    module ClassMethods
    #   def expand_hash_conditions_for_aggregates(attrs)
    #     expanded_attrs = {}
    #     attrs.each do |attr, value|
    #       # CPK
    #       # if aggregation = reflect_on_aggregation(attr.to_sym)
    #       if attr.is_a?(CompositePrimaryKeys::CompositeKeys)
    #         value = value.split('/') if value.is_a?(String)
    #         attr.each_with_index do |key,i|
    #           expanded_attrs[key] = value.respond_to?(:flatten) ? value.flatten[i] : value
    #         end
    #       elsif aggregation = reflect_on_aggregation(attr.to_sym)
    #         mapping = aggregation.mapping
    #         mapping.each do |field_attr, aggregate_attr|
    #           if mapping.size == 1 && !value.respond_to?(aggregate_attr)
    #             expanded_attrs[field_attr] = value
    #           else
    #             expanded_attrs[field_attr] = value.send(aggregate_attr)
    #           end
    #         end
    #       else
    #         expanded_attrs[attr] = value
    #       end
    #     end
    #     expanded_attrs
    #   end
    #
    #   def quoted_id
    #     # CPK
    #     # self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
    #     if self.composite?
    #       [self.class.primary_keys, ids].transpose.map { |attr_name,id|
    #         self.class.quote_value(@attributes[attr_name].value_for_database)
    #       }
    #     else
    #       self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
    #     end
    #   end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
composite_primary_keys-13.0.1 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-13.0.0 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.10 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.9 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.8 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.6 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.5 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.4 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.3 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.2 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.1 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0.rc5 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0.rc4 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0.rc3 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0.rc2 lib/composite_primary_keys/sanitization.rb
composite_primary_keys-12.0.0.rc1 lib/composite_primary_keys/sanitization.rb