Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/active_record/relation.rb

Instance Method Summary collapse

Instance Method Details

#where_values_hashObject


4
5
6
7
8
9
10
11
12
# File 'lib/patches/active_record/relation.rb', line 4

def where_values_hash
  _translations_table_name = klass.respond_to?(:translations_table_name) ? klass.translations_table_name : nil

  equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
    [table_name, _translations_table_name].compact.include? node.left.relation.name
  }

  Hash[equalities.map { |where| [where.left.name, where.right] }].with_indifferent_access
end