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 = {
|
58
|
+
query = {
|
59
|
+
taggable_class.tags.tag.name => tag_list.to_a,
|
59
60
|
Tagging.properties[:taggable_type] => taggable_class.to_s,
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
55
|
-
|
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
|
|
@@ -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
|