Module: ActiveTools::ActiveRecord::CustomCounterCache

Extended by:
ActiveSupport::Concern
Included in:
OnLoadActiveRecord
Defined in:
lib/active_tools/active_record/custom_counter_cache.rb,
lib/active_tools/active_record/custom_counter_cache/instance_methods.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.digger(owner, object, mapping) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/active_tools/active_record/custom_counter_cache.rb', line 45

def self.digger(owner, object, mapping)
  object.method_digger(mapping) do |object, key, response, value|
    if response && !response.is_a?(::ActiveRecord::Base)
      count = case value
      when String, Symbol then owner.send(value)
      when Fixnum then value
      end
      yield object, key, count          
    end
  end
end