genki-dm-is-taggable 0.1.5 → 0.1.6

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.
@@ -55,12 +55,16 @@ module DataMapper
55
55
  return rv
56
56
  end
57
57
 
58
- query = { taggable_class.tags.tag.name => tag_list.to_a,
58
+ query = {
59
+ taggable_class.tags.tag.name => tag_list.to_a,
59
60
  Tagging.properties[:taggable_type] => taggable_class.to_s,
60
- :unique => true
61
- }
62
- query.merge!(Tagging.properties[:tagger_type] => tagger_class) if tagger_class
63
- query.merge!(Tagging.properties[:tagger_id] => tagger_obj.id) if tagger_obj
61
+ :unique => true
62
+ }
63
+ query.merge!(Tagging.properties[:tagger_type] => tagger_class) if tagger_class
64
+ query.merge!(Tagging.properties[:tagger_id] => tagger_obj.id) if tagger_obj
65
+ (options.keys - [:match]).each do |key|
66
+ query[key] = options[key]
67
+ end
64
68
 
65
69
  unless options[:match] == :any
66
70
  conditions = "SELECT COUNT(DISTINCT(tag_id)) FROM taggings INNER JOIN tags ON taggings.tag_id = tags.id WHERE "
@@ -186,4 +190,4 @@ module DataMapper
186
190
  end # InstanceMethods
187
191
  end
188
192
  end
189
- end
193
+ end
@@ -51,8 +51,8 @@ module DataMapper
51
51
  def taggable_class;self;end
52
52
 
53
53
  def find(options)
54
- tagger, taggable, tags, options = extract_options(options)
55
- options.merge!(:on => self, :by =>tagger, :with => tags)
54
+ tagger, taggable, tags, options = extract_options(options)
55
+ options.merge!(:on => self, :by =>tagger, :with => tags)
56
56
  Tag.find_taggables(options)
57
57
  end
58
58
 
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module Taggable
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  DEPENDENCY_VERSION = ">= 0.9.6"
6
6
  end
7
7
  end
@@ -297,5 +297,10 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
297
297
  item[1].should be_a(Integer)
298
298
  end
299
299
  end
300
+
301
+ it "should be able to specify conditions over find method" do
302
+ result = Picture.find(:with => 'tag1', :id.not => [1])
303
+ result.map(&:id).should_not be_include(1)
304
+ end
300
305
  end
301
306
  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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian, Maxime Guilbot