foobara 0.0.68 → 0.0.69
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6aa740f8aa8c058877cd14db7cf69efdd0509bf39e790d7806d7e4f50309db3
|
4
|
+
data.tar.gz: 38fe1c5a5613cc0811d50c19209360f13d507a1dc0ef90d7208103940c6f4d1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c0b2ffa28dfadc479c34a86b212079b4ed49bab0506a49db213d9bb50b9d709e883c50208b5b28a86dffcf80f583d0cb2e3baad32536e680605f46529c10d71
|
7
|
+
data.tar.gz: c05caa4fd88b37c7b02bf522d965a550fe57e85d5382d98a81c3b7d970f6f091f7784e5069d0135c6694b757322d36c86770ab0fa3b5e832d930a548bd3becaa
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,9 @@ module Foobara
|
|
3
3
|
module Callbacks
|
4
4
|
include Concern
|
5
5
|
|
6
|
-
|
7
|
-
attr_accessor :callback_registry, :owner
|
6
|
+
attr_accessor :callback_registry
|
8
7
|
|
9
|
-
def initialize(
|
10
|
-
self.owner = owner
|
8
|
+
def initialize(...)
|
11
9
|
self.callback_registry = Callback::Registry::ChainedConditioned.new(self.class.class_callback_registry)
|
12
10
|
end
|
13
11
|
|
@@ -34,12 +34,36 @@ module Foobara
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
attr_accessor :
|
37
|
+
attr_accessor :target_attribute, :owner
|
38
|
+
|
39
|
+
# owner is optional. It can help with certain callbacks. It's also required if planning to use the target_attribute
|
40
|
+
# feature
|
41
|
+
def initialize(*args, owner: nil, target_attribute: nil, **options)
|
42
|
+
self.owner = owner
|
38
43
|
|
39
|
-
def initialize(*args, **options)
|
40
44
|
super
|
41
45
|
|
42
|
-
|
46
|
+
if target_attribute
|
47
|
+
self.target_attribute = target_attribute
|
48
|
+
else
|
49
|
+
self.current_state = self.class.initial_state
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def current_state
|
54
|
+
if target_attribute
|
55
|
+
owner.send(target_attribute) || self.class.initial_state
|
56
|
+
else
|
57
|
+
@current_state
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def current_state=(state)
|
62
|
+
if target_attribute
|
63
|
+
owner.send("#{target_attribute}=", state)
|
64
|
+
else
|
65
|
+
@current_state = state
|
66
|
+
end
|
43
67
|
end
|
44
68
|
|
45
69
|
def perform_transition!(transition, &block)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.69
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|