Class: ActiveRecord::Relation::WhereClauseFactory
- Inherits:
-
Object
- Object
- ActiveRecord::Relation::WhereClauseFactory
- Defined in:
- lib/active_record/relation/where_clause_factory.rb
Overview
:nodoc:
Instance Method Summary collapse
- #build(opts, other) ⇒ Object
-
#initialize(klass, predicate_builder) ⇒ WhereClauseFactory
constructor
A new instance of WhereClauseFactory.
Constructor Details
#initialize(klass, predicate_builder) ⇒ WhereClauseFactory
Returns a new instance of WhereClauseFactory.
6 7 8 9 |
# File 'lib/active_record/relation/where_clause_factory.rb', line 6 def initialize(klass, predicate_builder) @klass = klass @predicate_builder = predicate_builder end |
Instance Method Details
#build(opts, other) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_record/relation/where_clause_factory.rb', line 11 def build(opts, other) case opts when String, Array parts = [klass.sanitize_sql(other.empty? ? opts : ([opts] + other))] when Hash attributes = predicate_builder.resolve_column_aliases(opts) attributes.stringify_keys! parts = predicate_builder.build_from_hash(attributes) when Arel::Nodes::Node parts = [opts] else raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" end WhereClause.new(parts) end |