method
build
v5.1.7 -
Show latest stable
- Class:
ActiveRecord::Relation::WhereClauseFactory
build(opts, other)public
No documentation available.
# File activerecord/lib/active_record/relation/where_clause_factory.rb, line 9
def build(opts, other)
case opts
when String, Array
parts = [klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]
when Hash
attributes = predicate_builder.resolve_column_aliases(opts)
attributes = klass.send(:expand_hash_conditions_for_aggregates, attributes)
attributes.stringify_keys!
if perform_case_sensitive?(options = other.last)
parts, binds = build_for_case_sensitive(attributes, options)
else
attributes, binds = predicate_builder.create_binds(attributes)
parts = predicate_builder.build_from_hash(attributes)
end
when Arel::Nodes::Node
parts = [opts]
else
raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})"
end
WhereClause.new(parts, binds || [])
end