Module: ArCache::WhereClause::Raw

Included in:
ArCache::WhereClause
Defined in:
lib/ar_cache/where_clause.rb

Overview

This module is based on ActiveRecord::Relation::WhereClause modified

Instance Method Summary collapse

Instance Method Details

#where_values_hashObject Also known as: to_h



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ar_cache/where_clause.rb', line 109

def where_values_hash
  @where_values_hash ||= equalities(predicates).each_with_object({}) do |node, hash|
    # Don't support Arel::Nodes::NamedFunction.
    next if table.name != node.left.relation.name

    name = node.left.name.to_s
    value = extract_node_value(node.right)
    hash[name] = value
  end
rescue NoMethodError, ActiveModel::RangeError
  @where_values_hash = {}
end