counter_culture 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -143,6 +143,12 @@ Product.counter_culture_fix_counts :except => :category
143
143
  Product.counter_culture_fix_counts :only => :category
144
144
  # will automatically fix counts only on the :category relation on Product
145
145
 
146
+ # :except and :only also accept arrays of one level relations
147
+ # if you want to fix counts on a more than one level relation you need to use convention below:
148
+
149
+ Product.counter_culture_fix_counts :only => [[:subcategory, :category]]
150
+ # will automatically fix counts only on the two-level [:subcategory, :category] relation on Product
151
+
146
152
  # :except and :only also accept arrays
147
153
  ```
148
154
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "counter_culture"
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Magnus von Koeller"]
12
- s.date = "2012-09-17"
12
+ s.date = "2012-12-13"
13
13
  s.description = "counter_culture provides turbo-charged counter caches that are kept up-to-date not just on create and destroy, that support multiple levels of indirection through relationships, allow dynamic column names and that avoid deadlocks by updating in the after_commit callback."
14
14
  s.email = "magnus@vonkoeller.de"
15
15
  s.extra_rdoc_files = [
@@ -74,6 +74,8 @@ module CounterCulture
74
74
  # we are only interested in the id and the count of related objects (that's this class itself)
75
75
  query = klass.select("#{klass.table_name}.id, COUNT(#{self.table_name}.id) AS count")
76
76
  query = query.group("#{klass.table_name}.id")
77
+ # respect the deleted_at column if it exists
78
+ query = query.where("#{self.table_name}.deleted_at IS NULL") if self.column_names.include?('deleted_at')
77
79
 
78
80
  column_names = hash[:column_names] || {nil => hash[:counter_cache_name]}
79
81
  raise ":column_names must be a Hash of conditions and column names" unless column_names.is_a?(Hash)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: counter_culture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  segments:
220
220
  - 0
221
- hash: -255493455800926186
221
+ hash: -1683110651855926153
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  none: false
224
224
  requirements: