needle_in_a_haystack 1.0.2 → 1.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
  SHA256:
3
- metadata.gz: dcc57ef8ef5c022fd98794c87852be14133a293b05b765f5b1152384dbf4b944
4
- data.tar.gz: 67a37aa74001245538ba6e467e28bd3a1a23117a1452dcd1af8b5c68e6ef8ad0
3
+ metadata.gz: 47f3b28b275f615fb0cbfabb20d76cf70ef0adbf63875c6a2aae2c0b19e27e39
4
+ data.tar.gz: 9807a09a01410b9f299a268c828880df1e5fbbcf9cf6c7c16769b29da1fbb366
5
5
  SHA512:
6
- metadata.gz: bd9bfdf36861ad29009088e358833bca69a1612e078229d8cd4205a57386459bfaff8325cb967e474e7cc83b3df70b62586a8a9768ab8fb12c7ad3bb8176b40b
7
- data.tar.gz: b752e74b8f878ed842691f85cb4bd6e89cfe116e880769447a92ab3107daf2be6f979acd349d1e72cff9352d7e5177dd3005a513deabbec31ccdd6ca32b9c183
6
+ metadata.gz: a940a2d003014274c368e4daf453f1ab35711057eaec59a465d61ff3b319395806486fa95d3d19c7e4071f6c2e0e49cc6514079ce14b7921df722345ba9c651b
7
+ data.tar.gz: 29b755d8403392d44cb9561d2a119b1c5b61bb3ebbb269ea4b7f78c241280e396c34c52bb4a1d895e5474d9cf90bae4a74945214f31803724d4734b318a28239
@@ -0,0 +1,11 @@
1
+ class BaseTag < ApplicationRecord
2
+ self.abstract_class = true
3
+
4
+ def name
5
+ raise NotImplementedError, "Subclasses must implement a name-method"
6
+ end
7
+
8
+ def description
9
+ raise NotImplementedError, "Subclasses must implement a description-method"
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class BaseTagging < ApplicationRecord
2
+ self.abstract_class = true
3
+
4
+ def tag
5
+ raise NotImplementedError, "Subclasses must implement a tag-method"
6
+ end
7
+
8
+ def taggable
9
+ raise NotImplementedError, "Subclasses must implement a taggable-method"
10
+ end
11
+ end
@@ -1,4 +1,3 @@
1
- # app/models/concerns/taggable.rb
2
1
  module Taggable
3
2
  extend ActiveSupport::Concern
4
3
 
@@ -1,13 +1,21 @@
1
- class HaystackTag < ApplicationRecord
1
+ class HaystackTag < BaseTag
2
2
  belongs_to :parent_tag, class_name: "HaystackTag", optional: true
3
3
  has_many :children, class_name: "HaystackTag", foreign_key: "parent_tag_id", dependent: :destroy, inverse_of: :parent_tag
4
4
  has_many :haystack_taggings, dependent: :destroy
5
5
  has_many :taggables, through: :haystack_taggings
6
6
 
7
- validates :name, presence: true
7
+ validates :name, presence: true, uniqueness: true
8
8
  validates :description, presence: true
9
9
  validate :prevent_circular_reference
10
10
 
11
+ def name
12
+ self[:name]
13
+ end
14
+
15
+ def description
16
+ self[:description]
17
+ end
18
+
11
19
  def ancestors
12
20
  ancestors = []
13
21
  current = self
@@ -0,0 +1,4 @@
1
+ class HaystackTagging < BaseTagging
2
+ belongs_to :haystack_tag, class_name: "HaystackTag"
3
+ belongs_to :taggable, polymorphic: true
4
+ end
@@ -1 +1 @@
1
- VERSION = "1.0.2".freeze
1
+ VERSION = "1.0.3".freeze
@@ -2,8 +2,12 @@ require "needle_in_a_haystack/version"
2
2
  require "needle_in_a_haystack/engine"
3
3
  require "needle_in_a_haystack/application_record"
4
4
  require "needle_in_a_haystack/configuration"
5
- require "needle_in_a_haystack/haystack_tag"
6
- require "needle_in_a_haystack/haystack_tagging"
5
+ require "needle_in_a_haystack/concerns/base_tagging"
6
+ require "needle_in_a_haystack/concerns/base_tag"
7
+
8
+ require "needle_in_a_haystack/models/haystack_ontology"
9
+ require "needle_in_a_haystack/models/haystack_tag"
10
+ require "needle_in_a_haystack/models/haystack_tagging"
7
11
 
8
12
  module NeedleInAHaystack
9
13
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: needle_in_a_haystack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frans Verberne
@@ -275,14 +275,16 @@ files:
275
275
  - config/initializers/redis.rb
276
276
  - config/initializers/wrap_parameters.rb
277
277
  - config/locales/en.yml
278
- - lib/concerns/taggable.rb
279
278
  - lib/needle_in_a_haystack.rb
280
279
  - lib/needle_in_a_haystack/application_record.rb
280
+ - lib/needle_in_a_haystack/concerns/base_tag.rb
281
+ - lib/needle_in_a_haystack/concerns/base_tagging.rb
282
+ - lib/needle_in_a_haystack/concerns/taggable.rb
281
283
  - lib/needle_in_a_haystack/configuration.rb
282
284
  - lib/needle_in_a_haystack/engine.rb
283
- - lib/needle_in_a_haystack/haystack_ontology.rb
284
- - lib/needle_in_a_haystack/haystack_tag.rb
285
- - lib/needle_in_a_haystack/haystack_tagging.rb
285
+ - lib/needle_in_a_haystack/models/haystack_ontology.rb
286
+ - lib/needle_in_a_haystack/models/haystack_tag.rb
287
+ - lib/needle_in_a_haystack/models/haystack_tagging.rb
286
288
  - lib/needle_in_a_haystack/version.rb
287
289
  - lib/tasks/location_create.rake
288
290
  - spec/factories/haystack_tags.rb
@@ -1,4 +0,0 @@
1
- class HaystackTagging < ApplicationRecord
2
- belongs_to :haystack_tag
3
- belongs_to :taggable, polymorphic: true
4
- end