stance 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/app/models/stance/event_record.rb +1 -1
- data/lib/stance/event.rb +13 -6
- data/lib/stance/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f679d8376ef01172a2fe04995062885020f1810423df94a0621c3d863262267b
|
4
|
+
data.tar.gz: 2941c4c5af5f147eb0105294e19c3d23a7e9b8887fbc67661ea4e59bb14791f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '080ac5b578744bcd5103b049f103718b9bb8ffc5ef878893da96f4618e1097b4b5c4b3ea1296d4f8f06578701b2b2ddc881773623d20c76ce685755c97bf7954'
|
7
|
+
data.tar.gz: 7cdad4e4fd10b3c53081bbca1def4134efdb9d83ec5f4e40991e7238e2451d0b270a1874c27a0f4a1def5cc31f37bce238c893f7ffb03dcd013ab93c61e46c3b
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stance (0.8.
|
4
|
+
stance (0.8.2)
|
5
5
|
multi_json (~> 1.15)
|
6
6
|
rails (>= 7.0, < 8.0)
|
7
7
|
|
@@ -95,6 +95,9 @@ GEM
|
|
95
95
|
connection_pool (2.4.1)
|
96
96
|
crass (1.0.6)
|
97
97
|
date (3.3.4)
|
98
|
+
debug (1.9.1)
|
99
|
+
irb (~> 1.10)
|
100
|
+
reline (>= 0.3.8)
|
98
101
|
drb (2.2.0)
|
99
102
|
ruby2_keywords
|
100
103
|
erubi (1.12.0)
|
@@ -237,6 +240,7 @@ PLATFORMS
|
|
237
240
|
DEPENDENCIES
|
238
241
|
autotest-suffix
|
239
242
|
combustion
|
243
|
+
debug
|
240
244
|
minitest
|
241
245
|
minitest-autotest
|
242
246
|
minitest-focus
|
data/lib/stance/event.rb
CHANGED
@@ -8,6 +8,8 @@ module Stance
|
|
8
8
|
attr_reader :record, :options, :name
|
9
9
|
|
10
10
|
class << self
|
11
|
+
attr_accessor :callback_methods
|
12
|
+
|
11
13
|
def before_create(*methods, &block)
|
12
14
|
set_callback :create, :before, *methods, &block
|
13
15
|
end
|
@@ -15,6 +17,15 @@ module Stance
|
|
15
17
|
def after_create(*methods, &block)
|
16
18
|
set_callback :create, :after, *methods, &block
|
17
19
|
end
|
20
|
+
|
21
|
+
def method_added(method_name)
|
22
|
+
super
|
23
|
+
|
24
|
+
return if self == Stance::Event
|
25
|
+
|
26
|
+
self.callback_methods ||= []
|
27
|
+
self.callback_methods << method_name
|
28
|
+
end
|
18
29
|
end
|
19
30
|
|
20
31
|
def initialize(name, subject, metadata, options)
|
@@ -44,9 +55,9 @@ module Stance
|
|
44
55
|
run_callbacks :create do
|
45
56
|
# Call each public method of the Event class if a custom class.
|
46
57
|
if self.class.name != 'Stance::Event'
|
47
|
-
Rails.logger.
|
58
|
+
Rails.logger.debug "Event: #{full_name}"
|
48
59
|
|
49
|
-
callback_methods
|
60
|
+
self.class.callback_methods&.each { |method| send method }
|
50
61
|
end
|
51
62
|
|
52
63
|
record.save if @options[:record]
|
@@ -66,10 +77,6 @@ module Stance
|
|
66
77
|
|
67
78
|
private
|
68
79
|
|
69
|
-
def callback_methods
|
70
|
-
public_methods(false) - Stance::Event.instance_methods(false)
|
71
|
-
end
|
72
|
-
|
73
80
|
# Event is a singleton and already exists.
|
74
81
|
def singleton_exists?
|
75
82
|
options[:singleton] && subject.events.active.exists?(name: name)
|
data/lib/stance/version.rb
CHANGED