easy_tags 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 312d2148fbdb21f7a654cc811c25fefe5aad46befa9af7f6334b2cd5be127287
4
- data.tar.gz: 72f837865e19dfd7ea73f0db1a11f42c81f5c78e3db7608b5196ca152baf53d4
3
+ metadata.gz: 8a7f8eff9a1c48c2acd73b9e1508a60dd109e1093bc3d1907ac9d59ce84d1e6c
4
+ data.tar.gz: ee07bbd270d6430cf8282cb55a081567983c48eeda35c43dc42ed5850f8e4957
5
5
  SHA512:
6
- metadata.gz: fd12957155fe36706edeb580f3a97d1603fc5729ee9db7062f786cc430d1404d899793476a4f35643987b3e06d54188c4d538db86fd8a11e9603a043a692007d
7
- data.tar.gz: 5ccfa9bac407e740fe5b74e4c1c03d1bb2dedcc1d2207fccf14e1ae72714d639fca343805d6029241d81e5b50d539b5176b9b86912ae9825958549e6e44dab51
6
+ metadata.gz: '029a2218a20846732ad35ad4ee9801f242933624fa49dea7eb8ebd524c07c5bb477a83ff99fba5cae7aebb14bbac538b525e3ebfddcd02d6c43624d46d87d830'
7
+ data.tar.gz: 172a6b5c1af8643153b582e2bf04a3b3245214eea0f06ad52b7582099c11b0d11f815ab11679cf2f6a110571fcf791ec0e7a55eb601868a6c9a474aca784104d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2019-10-24
10
+ ### Fixed
11
+ - Fix `.add` and `.remove` methods not implementing properly dirty behavior
12
+
9
13
  ## [0.2.0] - 2019-09-12
10
14
  ### Added
11
15
  - `[context]_list_persisted` interface method for accessing persisted/previous tag list string
@@ -14,5 +18,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
18
  Initial release
15
19
 
16
20
  [Unreleased]: https://github.com/iiwo/easy_tagscompare/v0.2.0...HEAD
21
+ [0.2.1]: https://github.com/iiwo/easy_tags/compare/v0.2.0...v0.2.1
17
22
  [0.2.0]: https://github.com/iiwo/easy_tags/compare/v0.1.0...v0.2.0
18
23
  [0.1.0]: https://github.com/iiwo/easy_tags/releases/tag/v0.1.0
@@ -30,7 +30,7 @@ module EasyTags
30
30
  def update(value)
31
31
  @tags = TagList.new(value)
32
32
 
33
- on_change.call(self) if changed?
33
+ notify_change
34
34
  end
35
35
 
36
36
  # @return [TagList]
@@ -49,8 +49,46 @@ module EasyTags
49
49
  @persisted_tags = nil
50
50
  end
51
51
 
52
+ # Add tags to the tag_list. Duplicate or blank tags will be ignored.
53
+ #
54
+ # Example:
55
+ # tag_list.add('Fun', 'Happy')
56
+ def add(*names)
57
+ tags.add(*names).tap do
58
+ notify_change
59
+ end
60
+ end
61
+
62
+ # Remove item from list
63
+ #
64
+ # Example:
65
+ # tag_list.remove('Issues')
66
+ def remove(value)
67
+ tags.remove(value).tap do
68
+ notify_change
69
+ end
70
+ end
71
+
72
+ def ==(other)
73
+ to_a == other.to_a
74
+ end
75
+
52
76
  private
53
77
 
54
78
  attr_accessor :context, :refresh_persisted_tags, :on_change
79
+
80
+ def respond_to_missing?(name, _include_private = false)
81
+ tags.respond_to?(name)
82
+ end
83
+
84
+ def method_missing(name, *args, &block)
85
+ return super unless respond_to_missing?(name)
86
+
87
+ tags.send(name, *args, &block)
88
+ end
89
+
90
+ def notify_change
91
+ on_change.call(self) if changed?
92
+ end
55
93
  end
56
94
  end
@@ -33,7 +33,7 @@ module EasyTags
33
33
  attribute :#{context}_list, ActiveModel::Type::Value.new
34
34
 
35
35
  def #{context}
36
- _taggable_context(:#{context}).tags
36
+ _taggable_context(:#{context})
37
37
  end
38
38
 
39
39
  def #{context}=(value)
@@ -1,3 +1,3 @@
1
1
  module EasyTags
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iwo Dziechciarow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-13 00:00:00.000000000 Z
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord