Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaked init to match the usual convention

  • Loading branch information...
commit 91d29758dc8d1e8b8d05ce6f7421ce74f81291bf 1 parent d0e9213
@betamatt authored
Showing with 10 additions and 12 deletions.
  1. +10 −12 init.rb
View
22 init.rb
@@ -1,18 +1,16 @@
require 'passive_counter_cache'
-module ActiveRecord
- class Base
- class << self
- def belongs_to_with_passive_counter_cache(name, opts = {}, &block)
- if opts.delete(:passive_counter_cache)
- PassiveCounterCache.register_association_cache self, name, opts[:counter_cache] || "#{name.to_s}_count"
- opts[:counter_cache] = false
- end
-
- belongs_to_without_passive_counter_cache(name, opts, &block)
+ActiveRecord::Base.class_eval do
+ class << self
+ def belongs_to_with_passive_counter_cache(name, opts = {}, &block)
+ if opts.delete(:passive_counter_cache)
+ PassiveCounterCache.register_association_cache self, name, opts[:counter_cache] || "#{name.to_s}_count"
+ opts[:counter_cache] = false
end
-
- alias_method_chain :belongs_to, :passive_counter_cache
+
+ belongs_to_without_passive_counter_cache(name, opts, &block)
end
+
+ alias_method_chain :belongs_to, :passive_counter_cache
end
end

0 comments on commit 91d2975

Please sign in to comment.
Something went wrong with that request. Please try again.