foobara 0.0.67 → 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 +4 -4
- data/CHANGELOG.md +8 -0
- data/projects/domain/src/domain_module_extension.rb +2 -0
- data/projects/domain_mapper/src/domain_mapper.rb +1 -0
- data/projects/state_machine/src/callbacks.rb +2 -4
- data/projects/state_machine/src/state_machine.rb +27 -3
- data/projects/state_machine/src/transition_log.rb +1 -1
- data/projects/type_declarations/src/type_builder.rb +18 -0
- metadata +16 -2
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
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.69] - 2025-03-03
|
2
|
+
|
3
|
+
- Allow StateMachine to use an attribute on another object as its current state for convenience
|
4
|
+
|
5
|
+
## [0.0.68] - 2025-02-28
|
6
|
+
|
7
|
+
- Make use of LruCache for performance boost when converting type declarations to types
|
8
|
+
|
1
9
|
## [0.0.67] - 2025-02-26
|
2
10
|
|
3
11
|
- Convert / to _ when building constant names in Enumerated::Values
|
@@ -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)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "foobara/lru_cache"
|
2
|
+
|
1
3
|
module Foobara
|
2
4
|
module TypeDeclarations
|
3
5
|
class TypeBuilder
|
@@ -63,6 +65,12 @@ module Foobara
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def type_for_declaration(*type_declaration_bits, &block)
|
68
|
+
lru_cache.cached([type_declaration_bits, block]) do
|
69
|
+
type_for_declaration_without_cache(*type_declaration_bits, &block)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def type_for_declaration_without_cache(*type_declaration_bits, &block)
|
66
74
|
type_declaration = if block
|
67
75
|
unless type_declaration_bits.empty?
|
68
76
|
# :nocov:
|
@@ -88,8 +96,18 @@ module Foobara
|
|
88
96
|
handler.process_value!(type_declaration)
|
89
97
|
end
|
90
98
|
|
99
|
+
def clear_cache
|
100
|
+
if @lru_cache
|
101
|
+
lru_cache.reset!
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
91
105
|
private
|
92
106
|
|
107
|
+
def lru_cache
|
108
|
+
@lru_cache ||= Foobara::LruCache.new(100)
|
109
|
+
end
|
110
|
+
|
93
111
|
def type_declaration_bits_to_type_declaration(type_declaration_bits)
|
94
112
|
type, *symbolic_processors, processor_data = type_declaration_bits
|
95
113
|
|
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
|
@@ -23,6 +23,20 @@ dependencies:
|
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: foobara-lru-cache
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
26
40
|
- !ruby/object:Gem::Dependency
|
27
41
|
name: foobara-util
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|