polytag 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 900c32f5bee188416a150a2801f8687d1aa2810f
4
- data.tar.gz: 2f65f0c08c1eb95e6b09a7f84b241d142035bb3c
3
+ metadata.gz: b081aadd687235fc80ef0e6fe2ac99bdccf8edff
4
+ data.tar.gz: 559397b671a71e791ad423a0221260ca4112bb0c
5
5
  SHA512:
6
- metadata.gz: 284b2a7f67495e320d116961c9a17d98802e8fdbc82587c4490efcac3fdb52fdb7e1f3ebf733b610d73b372b04484aa3fdea64a003f1aee14460819b2fe686c3
7
- data.tar.gz: a141e950050b147fe47dae60b55d4ea225249326ea0624fc2aa3e411cb11e5a1b44f9a4f833bbe3086d971bace6c5d2eba042fedee9b48bfe225736d9b44e312
6
+ metadata.gz: a316be1f475ad261c166c43e3689091f70f4e98b881c195147400f71a62569eb7b3cd10add70f83965831d8a539a3075dedcd77d8f6e18d4e9613304384ae922
7
+ data.tar.gz: 8b37be6c30b19c9bf7ff2809bef05398f287fa36be499955c9765ceddea4b7669166932e84439a91f52faa44ca77274023e3fdf33361f09a8076d00c2839183a
data/lib/polytag.rb CHANGED
@@ -7,10 +7,18 @@ require "polytag/tag_relation"
7
7
  module Polytag
8
8
  def self.included(base)
9
9
  base.extend(ClassMethods)
10
- base.has_many :polytag_tag_relations, as: :tagged, class_name: '::Polytag::TagRelation'
11
- base.has_many :polytag_tags, through: :polytag_tag_relations, class_name: '::Polytag::Tag'
12
- base.__send__(:alias_method, :tag_relations, :polytag_tag_relations) unless base.method_defined?(:tag_relations)
13
- base.__send__(:alias_method, :tags, :polytag_tags) unless base.method_defined?(:tags)
10
+ base.has_many :polytag_tag_relations, class_name: '::Polytag::TagRelation',
11
+ as: :tagged
12
+
13
+ base.has_many :tag_relations, class_name: '::Polytag::TagRelation',
14
+ as: :tagged
15
+
16
+ base.has_many :polytag_tags, class_name: '::Polytag::Tag',
17
+ through: :polytag_tag_relations
18
+
19
+ base.has_many :tags, class_name: '::Polytag::Tag',
20
+ through: :polytag_tag_relations,
21
+ source: :polytag_tag
14
22
  end
15
23
 
16
24
  def tag_group(_tag_group = nil)
data/lib/polytag/tag.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  class Polytag::Tag < ActiveRecord::Base
2
2
  self.table_name = :polytag_tags
3
3
  belongs_to :polytag_tag_group, class_name: '::Polytag::TagGroup'
4
+ belongs_to :tag_group, class_name: '::Polytag::TagGroup',
5
+ foreign_key: :polytag_tag_group_id
6
+
4
7
  has_many :polytag_tag_relations, class_name: '::Polytag::TagRelation',
5
8
  foreign_key: :polytag_tag_id,
6
9
  dependent: :destroy
7
10
 
8
- alias_method :tag_group, :polytag_tag_group
9
- alias_method :relations, :polytag_tag_relations
11
+ has_many :relations, class_name: '::Polytag::TagRelation',
12
+ foreign_key: :polytag_tag_id,
13
+ dependent: :destroy
10
14
 
11
15
  # Indiscrimanetly get
12
16
  # the tagged models
13
17
  def tagged
14
- polytag_tag_relations.tagged
18
+ polytag_tag_relations.tagged.flatten
15
19
  end
16
20
 
17
21
  # Cleanup group if there are
@@ -1,11 +1,15 @@
1
1
  class Polytag::TagGroup < ActiveRecord::Base
2
2
  self.table_name = :polytag_tag_groups
3
+
3
4
  has_many :polytag_tag, class_name: '::Polytag::Tag',
4
5
  foreign_key: :polytag_tag_group_id,
5
6
  dependent: :destroy
6
7
 
8
+ has_many :tag, class_name: '::Polytag::Tag',
9
+ foreign_key: :polytag_tag_group_id,
10
+ dependent: :destroy
11
+
7
12
  belongs_to :owner, polymorphic: true
8
- alias_method :tag, :polytag_tag
9
13
 
10
14
  # Cleanup tag if there are
11
15
  # no more relations left on the tag
@@ -1,8 +1,17 @@
1
1
  module Polytag::TagGroup::Owner
2
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)
3
+ base.has_many :polytag_tag_groups, class_name: '::Polytag::TagGroup',
4
+ as: :owner
5
+
6
+ base.has_many :tag_groups, class_name: '::Polytag::TagGroup',
7
+ as: :owner
8
+
9
+ base.has_many :polytag_owned_tags, class_name: '::Polytag::Tag',
10
+ through: :polytag_tag_groups,
11
+ source: :polytag_tag
12
+
13
+ base.has_many :owned_tags, class_name: '::Polytag::Tag',
14
+ through: :polytag_tag_groups,
15
+ source: :polytag_tag
7
16
  end
8
17
  end
@@ -1,8 +1,8 @@
1
1
  class Polytag::TagRelation < ActiveRecord::Base
2
2
  self.table_name = :polytag_tag_relations
3
3
  belongs_to :polytag_tag, class_name: '::Polytag::Tag'
4
+ belongs_to :tag, class_name: '::Polytag::Tag', foreign_key: :polytag_tag_id
4
5
  belongs_to :tagged, polymorphic: true
5
- alias_method :tag, :polytag_tag
6
6
 
7
7
  # Cleanup tag if there are
8
8
  # no more relations left on the tag
@@ -1,3 +1,3 @@
1
1
  module Polytag
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Becker