core-state 0.1.2 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/core/state/version.rb +1 -1
- data/lib/is/stateful.rb +20 -15
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d8e18bc4a17547fa9177a538b991388f3e98dd37dcb98e6d87e76ac56c10b67
|
4
|
+
data.tar.gz: 9f6662fa3ed3d8c45495c5f3d07135e84323ea929d0725c2292b0fc3cdcb5b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6cbfec043568a05545f37a06407b869c484072043b45a16d7c6d7e52bfed2e00f9b6629c8ac14d898f4970c3415f4d286350f86fab8573cf2184c2ec227a3c
|
7
|
+
data.tar.gz: 86e0e24ac6324a28ddcf1153e10cfb5f65efe06a79240fef3d159f4bf851ebb1d81e2a8e6b0bb7aa496ddc7116faaae657aa1da06b1b7cf88bd91aea39a86b32
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## [v0.1.6](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
|
2
|
+
|
3
|
+
*released on 2021-11-02*
|
4
|
+
|
5
|
+
* `chg` [#97](https://github.com/metabahn/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
|
6
|
+
|
7
|
+
## [v0.1.5](https://github.com/metabahn/corerb/releases/tag/2021-10-22)
|
8
|
+
|
9
|
+
*released on 2021-10-22*
|
10
|
+
|
11
|
+
* `fix` [#88](https://github.com/metabahn/corerb/pull/88) Fix an issue causing state to be shared between sibling subclasses ([bryanp](https://github.com/bryanp))
|
12
|
+
|
13
|
+
## [v0.1.4](https://github.com/metabahn/corerb/releases/tag/2021-09-30)
|
14
|
+
|
15
|
+
*released on 2021-09-30*
|
16
|
+
|
17
|
+
* `fix` [#85](https://github.com/metabahn/corerb/pull/85) Initialize with class-level state when available ([bryanp](https://github.com/bryanp))
|
18
|
+
|
19
|
+
## [v0.1.3](https://github.com/metabahn/corerb/releases/tag/2021-09-28)
|
20
|
+
|
21
|
+
*released on 2021-09-28*
|
22
|
+
|
23
|
+
* `fix` [#84](https://github.com/metabahn/corerb/pull/84) Define core-local as a dependency of core-state ([bryanp](https://github.com/bryanp))
|
24
|
+
|
1
25
|
## [v0.1.1](https://github.com/metabahn/corerb/releases/tag/2021-07-15)
|
2
26
|
|
3
27
|
*released on 2021-07-15*
|
data/lib/core/state/version.rb
CHANGED
data/lib/is/stateful.rb
CHANGED
@@ -7,14 +7,12 @@ module Is
|
|
7
7
|
# [public] Makes objects stateful.
|
8
8
|
#
|
9
9
|
module Stateful
|
10
|
-
# Adding core-copy as a dependency
|
10
|
+
# Adding core-copy as a dependency creates a recursive dependency, so just bundle it.
|
11
11
|
#
|
12
12
|
module Copy
|
13
13
|
DEFAULT = ::Object.new
|
14
14
|
|
15
15
|
refine ::Object do
|
16
|
-
# [public] Copies the object using `clone`.
|
17
|
-
#
|
18
16
|
if RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
|
19
17
|
def copy(freeze: DEFAULT)
|
20
18
|
should_freeze = resolve_freeze_argument(freeze)
|
@@ -40,8 +38,6 @@ module Is
|
|
40
38
|
end
|
41
39
|
|
42
40
|
refine Array do
|
43
|
-
# [public] Copies the array, along with each value.
|
44
|
-
#
|
45
41
|
def copy(freeze: DEFAULT)
|
46
42
|
unless Stateful.copying?(self)
|
47
43
|
Stateful.prevent_recursion(self) do
|
@@ -58,8 +54,6 @@ module Is
|
|
58
54
|
end
|
59
55
|
|
60
56
|
refine Hash do
|
61
|
-
# [public] Copies the hash, along with each key and value.
|
62
|
-
#
|
63
57
|
def copy(freeze: DEFAULT)
|
64
58
|
unless Stateful.copying?(self)
|
65
59
|
Stateful.prevent_recursion(self) do
|
@@ -122,6 +116,10 @@ module Is
|
|
122
116
|
defined_state[ivar_name] = state
|
123
117
|
defined_state_isolations << ivar_name
|
124
118
|
|
119
|
+
if state[:class]
|
120
|
+
instance_variable_set(ivar_name, default)
|
121
|
+
end
|
122
|
+
|
125
123
|
prefix = if private
|
126
124
|
"private "
|
127
125
|
else
|
@@ -188,21 +186,23 @@ module Is
|
|
188
186
|
end
|
189
187
|
|
190
188
|
subclass.send(:prepend_defined_state_modules)
|
191
|
-
subclass.instance_variable_set("@
|
189
|
+
subclass.instance_variable_set("@__defined_state__", @__defined_state__.each_with_object({}) { |(key, value), state|
|
190
|
+
state[key] = value.dup
|
191
|
+
})
|
192
192
|
|
193
193
|
super
|
194
194
|
end
|
195
195
|
|
196
196
|
private def defined_state
|
197
|
-
@
|
197
|
+
@__defined_state__ ||= {}
|
198
198
|
end
|
199
199
|
|
200
200
|
private def defined_state_class_module
|
201
|
-
@
|
201
|
+
@__defined_state_class_module__ ||= Module.new
|
202
202
|
end
|
203
203
|
|
204
204
|
private def defined_state_instance_module
|
205
|
-
@
|
205
|
+
@__defined_state_instance_module__ ||= Module.new
|
206
206
|
end
|
207
207
|
|
208
208
|
private def prepend_defined_state_modules
|
@@ -239,9 +239,14 @@ module Is
|
|
239
239
|
|
240
240
|
extends :implementation, prepend: true do
|
241
241
|
def initialize(...)
|
242
|
-
self.class
|
242
|
+
self_class = self.class
|
243
|
+
self_class.send(:defined_state).each_pair do |name, state|
|
243
244
|
if state[:instance]
|
244
|
-
|
245
|
+
if state[:class]
|
246
|
+
instance_variable_set(name, self_class.instance_variable_get(name))
|
247
|
+
else
|
248
|
+
instance_variable_set(name, state[:value])
|
249
|
+
end
|
245
250
|
end
|
246
251
|
end
|
247
252
|
|
@@ -249,7 +254,7 @@ module Is
|
|
249
254
|
end
|
250
255
|
|
251
256
|
def initialize_copy(...)
|
252
|
-
@
|
257
|
+
@__defined_state_isolations__ = []
|
253
258
|
|
254
259
|
super
|
255
260
|
end
|
@@ -263,7 +268,7 @@ module Is
|
|
263
268
|
end
|
264
269
|
|
265
270
|
private def defined_state_isolations
|
266
|
-
@
|
271
|
+
@__defined_state_isolations__ ||= []
|
267
272
|
end
|
268
273
|
end
|
269
274
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core-state
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-extension
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: core-local
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
27
41
|
description: Easily manage object state.
|
28
42
|
email: bryan@metabahn.com
|
29
43
|
executables: []
|
@@ -54,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '0'
|
56
70
|
requirements: []
|
57
|
-
rubygems_version: 3.2.
|
71
|
+
rubygems_version: 3.2.22
|
58
72
|
signing_key:
|
59
73
|
specification_version: 4
|
60
74
|
summary: Easily manage object state.
|