class ActiveRecord::PredicateBuilder::AssociationQueryValue
Public Instance Methods
ids()
click to toggle source
# File lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb, line 19 def ids case value when Relation value.select_values.empty? ? value.select(primary_key) : value when Array value.map { |v| convert_to_id(v) } else # CPK # convert_to_id(value) if value.nil? nil elsif value.respond_to?(:composite?) && value.composite? value.class.primary_keys.zip(value.id) else convert_to_id(value) end end end
queries()
click to toggle source
# File lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb, line 4 def queries # CPK if associated_table.join_foreign_key.is_a?(Array) if ids.is_a?(ActiveRecord::Relation) ids.map do |id| associated_table.join_foreign_key.zip(id.id).to_h end else [associated_table.join_foreign_key.zip(ids).to_h] end else [associated_table.join_foreign_key => ids] end end