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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6d4b2e842f885c1ac09bcf1cc4660712164f336
4
- data.tar.gz: 52c8c36367c902a736735c68de3fb224cb94a4f4
3
+ metadata.gz: 900c32f5bee188416a150a2801f8687d1aa2810f
4
+ data.tar.gz: 2f65f0c08c1eb95e6b09a7f84b241d142035bb3c
5
5
  SHA512:
6
- metadata.gz: 55e8dac4832358fa356f6573e5d67252e547a309826641782cacc224b6dec2645245cd8b7ca9d90d212a9d0bfead1eae88cf1c067def7c705e6bc44cca01c7db
7
- data.tar.gz: a64fe6106e4c2b6aaaeef87ed9c04f87857e1cab3663dcab4f53fe52312d7200230e37924386a2e21eb671d8aea794f23e7d4f3fd29f7a7291150b95579ec369
6
+ metadata.gz: 284b2a7f67495e320d116961c9a17d98802e8fdbc82587c4490efcac3fdb52fdb7e1f3ebf733b610d73b372b04484aa3fdea64a003f1aee14460819b2fe686c3
7
+ data.tar.gz: a141e950050b147fe47dae60b55d4ea225249326ea0624fc2aa3e411cb11e5a1b44f9a4f833bbe3086d971bace6c5d2eba042fedee9b48bfe225736d9b44e312
@@ -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 || P{}) }
38
+ _tags.map { |x| add_tag(x, _tag_group || {}) }
38
39
  end
39
40
 
40
41
  def add_tags!(*_tags)
@@ -11,15 +11,15 @@ class Polytag::Tag < ActiveRecord::Base
11
11
  # Indiscrimanetly get
12
12
  # the tagged models
13
13
  def tagged
14
- relations.tagged
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
- tag_group.reload
21
- if tag_group.tags.count < 0
22
- tag_group.destroy
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
@@ -1,6 +1,7 @@
1
1
  class Polytag::TagGroup < ActiveRecord::Base
2
2
  self.table_name = :polytag_tag_groups
3
3
  has_many :polytag_tag, class_name: '::Polytag::Tag',
4
+ foreign_key: :polytag_tag_group_id,
4
5
  dependent: :destroy
5
6
 
6
7
  belongs_to :owner, polymorphic: true
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Polytag
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,2 +1,3 @@
1
1
  class Owner < ActiveRecord::Base
2
+ include Polytag::TagGroup::Owner
2
3
  end
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.2
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