beaconable 0.2.1 → 0.3.3
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 +4 -4
- data/CHANGELOG.md +33 -0
- data/Gemfile.lock +14 -14
- data/README.md +1 -0
- data/beaconable.gemspec +1 -1
- data/lib/beaconable.rb +9 -6
- data/lib/beaconable/base_beacon.rb +5 -1
- data/lib/beaconable/object_was.rb +1 -1
- data/lib/beaconable/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d63120af45f37b54ab3020114dd38b0d4e0b713905502a8f00c0897d998a70
|
4
|
+
data.tar.gz: 83665ce72cf9935939f831fac3b71c1182185dea3afe03087ff56e5b083a3c61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4e95173a8da6acb6ee8f7b9776ade78a074b3578c8127b6b97da6433110a191ad6fab8df609ee851005d3893d35cd305adf6d14068163a33d1b431b6947f99
|
7
|
+
data.tar.gz: 329e7e0710ec294b3f243116ea61b2afe9d823f853669eb7b24492e81a21e751afe98ea801f68b34e9fc2dab0186e0eb5c467bfbb08c03d40c923b5795af05f5
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
## 0.3.3 (2020-11-02)
|
2
|
+
|
3
|
+
- Fixes a bug that causes an error when a beaconable was touch by an association without changes
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
- Add `#skip_beacon` method to included clases
|
7
|
+
|
8
|
+
## 0.3.2 (2020-10-07)
|
9
|
+
|
10
|
+
### Improvements
|
11
|
+
- Add `#destroyed_entry?` method
|
12
|
+
|
13
|
+
## 0.3.1 (2020-09-16)
|
14
|
+
|
15
|
+
- Fixes #fire_beacon not to use dirty attributes to check changes
|
16
|
+
|
17
|
+
## 0.3.0 (2020-08-03)
|
18
|
+
|
19
|
+
- Changed ObjectWas initialization to wrap al all the changes for a transaction
|
20
|
+
|
21
|
+
## 0.2.2 (2019-12-16)
|
22
|
+
|
23
|
+
- Added new tests for chained methods
|
24
|
+
- Fixed chained methods
|
25
|
+
|
26
|
+
## 0.2.1 (2019-12-16)
|
27
|
+
|
28
|
+
- Made #field_change, #from and #to public
|
29
|
+
|
30
|
+
## 0.2.0 (2019-12-12)
|
31
|
+
|
32
|
+
- Added new test and fixes styles
|
33
|
+
- Added #field_change, #from, #to
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
beaconable (0.
|
4
|
+
beaconable (0.3.3)
|
5
5
|
activerecord (>= 4.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (6.0.
|
11
|
-
activesupport (= 6.0.
|
12
|
-
activerecord (6.0.
|
13
|
-
activemodel (= 6.0.
|
14
|
-
activesupport (= 6.0.
|
15
|
-
activesupport (6.0.
|
10
|
+
activemodel (6.0.3.1)
|
11
|
+
activesupport (= 6.0.3.1)
|
12
|
+
activerecord (6.0.3.1)
|
13
|
+
activemodel (= 6.0.3.1)
|
14
|
+
activesupport (= 6.0.3.1)
|
15
|
+
activesupport (6.0.3.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 0.7, < 2)
|
18
18
|
minitest (~> 5.1)
|
19
19
|
tzinfo (~> 1.1)
|
20
|
-
zeitwerk (~> 2.
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
21
|
ansi (1.5.0)
|
22
22
|
ast (2.4.0)
|
23
23
|
builder (3.2.3)
|
24
24
|
byebug (10.0.2)
|
25
|
-
concurrent-ruby (1.1.
|
26
|
-
i18n (1.
|
25
|
+
concurrent-ruby (1.1.6)
|
26
|
+
i18n (1.8.2)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
28
|
jaro_winkler (1.5.3)
|
29
29
|
minitest (5.11.3)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
parser (2.6.3.0)
|
37
37
|
ast (~> 2.4.0)
|
38
38
|
rainbow (3.0.0)
|
39
|
-
rake (
|
39
|
+
rake (13.0.1)
|
40
40
|
rubocop (0.74.0)
|
41
41
|
jaro_winkler (~> 1.5.1)
|
42
42
|
parallel (~> 1.10)
|
@@ -47,10 +47,10 @@ GEM
|
|
47
47
|
ruby-progressbar (1.10.1)
|
48
48
|
sqlite3 (1.4.1)
|
49
49
|
thread_safe (0.3.6)
|
50
|
-
tzinfo (1.2.
|
50
|
+
tzinfo (1.2.7)
|
51
51
|
thread_safe (~> 0.1)
|
52
52
|
unicode-display_width (1.6.0)
|
53
|
-
zeitwerk (2.
|
53
|
+
zeitwerk (2.3.0)
|
54
54
|
|
55
55
|
PLATFORMS
|
56
56
|
ruby
|
@@ -61,7 +61,7 @@ DEPENDENCIES
|
|
61
61
|
byebug (~> 10.0)
|
62
62
|
minitest (~> 5.0)
|
63
63
|
minitest-reporters (~> 1.3)
|
64
|
-
rake (~>
|
64
|
+
rake (~> 13.0)
|
65
65
|
rubocop (~> 0.74.0)
|
66
66
|
sqlite3 (~> 1.3)
|
67
67
|
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ When you include Beaconable in your model it will fire your Beacon everytime aft
|
|
28
28
|
- field_changed?(:field_name) : It allows you to check if a specific field was modified.
|
29
29
|
- any_field_changed?(:field_name, :other_field_name) : It allows you to check if any of multiple fields was modified.
|
30
30
|
- new_entry? : Returns true if the item saved is new
|
31
|
+
- destroyed_entry? : Returns true if the item has been destroyed
|
31
32
|
|
32
33
|
You can also used the following chained methods
|
33
34
|
- field_change(:field_name).from('first_alternative', 'n_alternative').to('first_alternative_for_to', 'second_alternative_for_to', 'n_alternative_for_toq')
|
data/beaconable.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
36
36
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
37
37
|
spec.add_development_dependency 'minitest-reporters', '~> 1.3'
|
38
|
-
spec.add_development_dependency 'rake', '~>
|
38
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
39
39
|
spec.add_development_dependency 'rubocop', '~> 0.74.0'
|
40
40
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
41
41
|
spec.add_development_dependency 'byebug', '~> 10.0'
|
data/lib/beaconable.rb
CHANGED
@@ -8,19 +8,22 @@ require 'active_record'
|
|
8
8
|
module Beaconable
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
included do
|
11
|
-
|
12
|
-
|
11
|
+
attr_accessor :skip_beacon
|
12
|
+
|
13
|
+
before_save :save_for_beacon, unless: :skip_beacon
|
14
|
+
before_destroy :save_for_beacon, unless: :skip_beacon
|
15
|
+
after_touch :save_for_beacon, unless: :skip_beacon
|
16
|
+
after_commit :fire_beacon, unless: :skip_beacon
|
13
17
|
end
|
14
18
|
|
15
19
|
private
|
16
20
|
|
17
21
|
def save_for_beacon
|
18
|
-
@object_was
|
22
|
+
@object_was ||= ObjectWas.new(self).call
|
19
23
|
end
|
20
24
|
|
21
25
|
def fire_beacon
|
22
|
-
|
23
|
-
|
24
|
-
end
|
26
|
+
"#{self.class.name}Beacon".constantize.new(self, @object_was).call
|
27
|
+
@object_was = nil
|
25
28
|
end
|
26
29
|
end
|
@@ -23,11 +23,15 @@ module Beaconable
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to(*values)
|
26
|
-
@result
|
26
|
+
@result && values.include?(object.send(@field))
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def destroyed_entry?
|
32
|
+
object.destroyed?
|
33
|
+
end
|
34
|
+
|
31
35
|
def field_changed?(field)
|
32
36
|
object.send(field) != object_was.send(field)
|
33
37
|
end
|
@@ -10,7 +10,7 @@ module Beaconable
|
|
10
10
|
|
11
11
|
def call
|
12
12
|
hashed_object = {}
|
13
|
-
symbolized_column_names = object.class.column_names.map
|
13
|
+
symbolized_column_names = object.class.column_names.map(&:to_sym)
|
14
14
|
symbolized_column_names.each do |column_name|
|
15
15
|
hashed_object[column_name] = object.send("#{column_name}_was")
|
16
16
|
end
|
data/lib/beaconable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaconable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerardo Raiden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- CODE_OF_CONDUCT.md
|
136
137
|
- Gemfile
|
137
138
|
- Gemfile.lock
|