polytag 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/polytag.rb +2 -1
- data/lib/polytag/tag.rb +4 -4
- data/lib/polytag/tag_group.rb +1 -0
- data/lib/polytag/tag_group/owner.rb +8 -0
- data/lib/polytag/version.rb +1 -1
- data/spec/support/owner.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900c32f5bee188416a150a2801f8687d1aa2810f
|
4
|
+
data.tar.gz: 2f65f0c08c1eb95e6b09a7f84b241d142035bb3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 284b2a7f67495e320d116961c9a17d98802e8fdbc82587c4490efcac3fdb52fdb7e1f3ebf733b610d73b372b04484aa3fdea64a003f1aee14460819b2fe686c3
|
7
|
+
data.tar.gz: a141e950050b147fe47dae60b55d4ea225249326ea0624fc2aa3e411cb11e5a1b44f9a4f833bbe3086d971bace6c5d2eba042fedee9b48bfe225736d9b44e312
|
data/lib/polytag.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "polytag/version"
|
2
2
|
require "polytag/tag"
|
3
3
|
require "polytag/tag_group"
|
4
|
+
require "polytag/tag_group/owner"
|
4
5
|
require "polytag/tag_relation"
|
5
6
|
|
6
7
|
module Polytag
|
@@ -34,7 +35,7 @@ module Polytag
|
|
34
35
|
|
35
36
|
def add_tags(*_tags)
|
36
37
|
_tag_group = _tags.pop if _tags.last.is_a?(Hash)
|
37
|
-
_tags.map { |x| add_tag(x, _tag_group ||
|
38
|
+
_tags.map { |x| add_tag(x, _tag_group || {}) }
|
38
39
|
end
|
39
40
|
|
40
41
|
def add_tags!(*_tags)
|
data/lib/polytag/tag.rb
CHANGED
@@ -11,15 +11,15 @@ class Polytag::Tag < ActiveRecord::Base
|
|
11
11
|
# Indiscrimanetly get
|
12
12
|
# the tagged models
|
13
13
|
def tagged
|
14
|
-
|
14
|
+
polytag_tag_relations.tagged
|
15
15
|
end
|
16
16
|
|
17
17
|
# Cleanup group if there are
|
18
18
|
# no more tags left on the group
|
19
19
|
after_destroy do
|
20
|
-
|
21
|
-
if
|
22
|
-
|
20
|
+
polytag_tag_group.reload
|
21
|
+
if polytag_tag_group.tags.count < 0
|
22
|
+
polytag_tag_group.destroy
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/polytag/tag_group.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
module Polytag::TagGroup::Owner
|
2
|
+
def self.included(base)
|
3
|
+
base.has_many :polytag_tag_groups, as: :owner, class_name: '::Polytag::TagGroup'
|
4
|
+
base.has_many :polytag_owned_tags, through: :polytag_tag_groups, source: :polytag_tag, class_name: '::Polytag::Tag'
|
5
|
+
base.__send__(:alias_method, :tag_groups, :polytag_tag_groups) unless base.method_defined?(:tag_relations)
|
6
|
+
base.__send__(:alias_method, :owned_tags, :polytag_owned_tags) unless base.method_defined?(:owned_tags)
|
7
|
+
end
|
8
|
+
end
|
data/lib/polytag/version.rb
CHANGED
data/spec/support/owner.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polytag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Becker
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/polytag.rb
|
142
142
|
- lib/polytag/tag.rb
|
143
143
|
- lib/polytag/tag_group.rb
|
144
|
+
- lib/polytag/tag_group/owner.rb
|
144
145
|
- lib/polytag/tag_relation.rb
|
145
146
|
- lib/polytag/version.rb
|
146
147
|
- polytag.gemspec
|