Class: ActiveRecord::Relation::HashMerger
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/relation/merger.rb |
Class Method Summary
- .new(relation, hash) ⇒ HashMerger constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(relation, hash) ⇒ HashMerger
Instance Attribute Details
#hash (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/relation/merger.rb', line 8
attr_reader :relation, :hash
#relation (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/relation/merger.rb', line 8
attr_reader :relation, :hash
Instance Method Details
#merge
[ GitHub ]#other
Applying values to a relation has some side effects. E.g
. interpolation might take place for where values. So we should build a relation to merge in rather than directly merging the values.
# File 'activerecord/lib/active_record/relation/merger.rb', line 25
def other other = Relation.create( relation.model, table: relation.table, predicate_builder: relation.predicate_builder ) hash.each do |k, v| k = :_select if k == :select if Array === v other.public_send("#{k}!", *v) else other.public_send("#{k}!", v) end end other end