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



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/ar_cache/where_clause.rb', line 100

def where_values_hash
  @where_values_hash ||= equalities(predicates).each_with_object({}) do |node, hash|
    # Don't support Arel::Nodes::NamedFunction.
    # But we don't judge it, because it will raise exception if it is Arel::Nodes::NamedFunction object.
    next if table.name != node.left.relation.name

    name = node.left.name.to_s
    value = extract_node_value(node.right)
    next if value.respond_to?(:size) && value.size > ArCache::Configuration.column_length

    hash[name] = value
  end
rescue NoMethodError, ActiveModel::RangeError
  @where_values_hash = {}
end