genki-dm-is-taggable 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,13 +57,7 @@ module DataMapper
57
57
  end
58
58
 
59
59
  def total(options = {})
60
- property = DataMapper::Property.new(Tagging, :"count(*)", Integer)
61
- order = options[:order] || :desc
62
- dir = DataMapper::Query::Direction.new(property, order)
63
- tag_id_to_count = Tagging.aggregate(:all.count,
64
- options.merge(:fields => [:tag_id], :order => [dir]))
65
- tag_ids, counts = tag_id_to_count.transpose
66
- Tag.all(:id => tag_ids).zip counts
60
+ Tagging.total(options.merge(:taggable_type => self.name))
67
61
  end
68
62
  end # ClassMethods
69
63
 
@@ -21,6 +21,15 @@ module DataMapper
21
21
  end
22
22
 
23
23
  module TaggingClassMethods
24
+ def total(options = {})
25
+ property = DataMapper::Property.new(Tagging, :"count(*)", Integer)
26
+ order = options[:order] || :desc
27
+ dir = DataMapper::Query::Direction.new(property, order)
28
+ tag_id_to_count = Tagging.aggregate(:all.count,
29
+ options.merge(:fields => [:tag_id], :order => [dir]))
30
+ tag_ids, counts = tag_id_to_count.transpose
31
+ Tag.all(:id => tag_ids).zip counts
32
+ end
24
33
  end
25
34
 
26
35
  module TaggingInstanceMethods
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module Taggable
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  DEPENDENCY_VERSION = ">= 0.9.6"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genki-dm-is-taggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian, Maxime Guilbot
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-08 00:00:00 -07:00
12
+ date: 2009-05-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency