l43_open_object 0.4.3 → 0.5.0
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/lib/l43/open_object/version.rb +1 -1
- data/lib/l43/{typed_object → typed_class}/behavior.rb +1 -1
- data/lib/l43/{typed_object → typed_class}/constants.rb +1 -1
- data/lib/l43/typed_class/description/hidden.rb +34 -0
- data/lib/l43/typed_class/description.rb +25 -0
- data/lib/l43/{typed_object → typed_class}/impl_helper.rb +1 -1
- data/lib/l43/{typed_object → typed_class}/implementation.rb +1 -1
- data/lib/l43/{typed_object.rb → typed_class.rb} +7 -5
- metadata +8 -7
- data/lib/l43/typed_object/description.rb +0 -45
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59563ce9436ed3a998820c2b36f05e3b488cea636559747c2b83953d6f1fc940
|
|
4
|
+
data.tar.gz: 756c5fc1aae48e18e55ed1bf9ec6439d01c83f00248ddaabf87abd4c9cfec307
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 847d38dc2b7cd2bb8fe789d08af7176d491f1747ae70c8808941e0a9d875e95892087aa9310fbb254af92d5d05a4703c79213853c3ef250e393781162c7e0c30
|
|
7
|
+
data.tar.gz: d12585ca4e5f3666e8796ea0fbf77fac8f32c67912e5c15d40674499f7f7fa6bffbc428186fa5a1a0221e26db0e3d59d553da8bcc500a81758c6f49643900768
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module L43
|
|
4
|
+
module TypedClass
|
|
5
|
+
class Description
|
|
6
|
+
module Hidden
|
|
7
|
+
def check_types!
|
|
8
|
+
ImplHelper.check_value_errors!(args: defaults, attributes:)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def implement =
|
|
12
|
+
Implementation.new(klass:, attributes:, defaults:, callable:)
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
def attributes = @__atts_6B9l39xVLR8UnX5U.freeze
|
|
16
|
+
def callable = @__callable_6B9l39xVLR8UnX5U
|
|
17
|
+
|
|
18
|
+
attr_reader :klass
|
|
19
|
+
|
|
20
|
+
def defaults
|
|
21
|
+
@__defaults__ ||= attributes.inject({}) do |defaults, (name, desc)|
|
|
22
|
+
if desc.default == None
|
|
23
|
+
defaults
|
|
24
|
+
else
|
|
25
|
+
defaults.merge(name => desc.default)
|
|
26
|
+
end
|
|
27
|
+
end.freeze
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ostruct'
|
|
4
|
+
require_relative 'implementation'
|
|
5
|
+
module L43
|
|
6
|
+
module TypedClass
|
|
7
|
+
class Description
|
|
8
|
+
private
|
|
9
|
+
def initialize(klass)
|
|
10
|
+
@klass = klass
|
|
11
|
+
@__atts_6B9l39xVLR8UnX5U = {}
|
|
12
|
+
@__callable_6B9l39xVLR8UnX5U = nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def attr(name, default: None, as: None, &blk)
|
|
16
|
+
@__atts_6B9l39xVLR8UnX5U.update(name => OpenStruct.new(default:, type: as, constraint: blk))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def make_callable(&blk)
|
|
20
|
+
@__callable_6B9l39xVLR8UnX5U = blk
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative '
|
|
4
|
-
require_relative '
|
|
3
|
+
require_relative 'typed_class/constants'
|
|
4
|
+
require_relative 'typed_class/description'
|
|
5
|
+
require_relative 'typed_class/description/hidden'
|
|
5
6
|
module L43
|
|
6
|
-
module
|
|
7
|
+
module TypedClass
|
|
7
8
|
def def_atts(&blk)
|
|
8
9
|
desc = Description.new(self)
|
|
9
10
|
desc.instance_eval(&blk)
|
|
11
|
+
desc.extend Description::Hidden
|
|
10
12
|
desc.check_types!
|
|
11
13
|
desc.implement
|
|
12
14
|
end
|
|
@@ -21,9 +23,9 @@ module L43
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def make(&blk)
|
|
24
|
-
|
|
26
|
+
typed_class = self
|
|
25
27
|
Class.new do
|
|
26
|
-
extend
|
|
28
|
+
extend typed_class
|
|
27
29
|
def_atts(&blk)
|
|
28
30
|
end
|
|
29
31
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: l43_open_object
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Dober
|
|
@@ -42,12 +42,13 @@ files:
|
|
|
42
42
|
- lib/l43/open_object/behavior.rb
|
|
43
43
|
- lib/l43/open_object/initializer.rb
|
|
44
44
|
- lib/l43/open_object/version.rb
|
|
45
|
-
- lib/l43/
|
|
46
|
-
- lib/l43/
|
|
47
|
-
- lib/l43/
|
|
48
|
-
- lib/l43/
|
|
49
|
-
- lib/l43/
|
|
50
|
-
- lib/l43/
|
|
45
|
+
- lib/l43/typed_class.rb
|
|
46
|
+
- lib/l43/typed_class/behavior.rb
|
|
47
|
+
- lib/l43/typed_class/constants.rb
|
|
48
|
+
- lib/l43/typed_class/description.rb
|
|
49
|
+
- lib/l43/typed_class/description/hidden.rb
|
|
50
|
+
- lib/l43/typed_class/impl_helper.rb
|
|
51
|
+
- lib/l43/typed_class/implementation.rb
|
|
51
52
|
homepage: https://codeberg.org/lab419/l43_open_object
|
|
52
53
|
licenses:
|
|
53
54
|
- AGPL-3.0-or-later
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ostruct'
|
|
4
|
-
require_relative 'implementation'
|
|
5
|
-
module L43
|
|
6
|
-
module TypedObject
|
|
7
|
-
class Description
|
|
8
|
-
|
|
9
|
-
def check_types!
|
|
10
|
-
ImplHelper.check_value_errors!(args: defaults, attributes:)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def implement =
|
|
14
|
-
Implementation.new(klass:, attributes: attributes.freeze, defaults:, callable:)
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
attr_reader :allowed, :callable, :klass, :required
|
|
18
|
-
def initialize(klass)
|
|
19
|
-
@klass = klass
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def attr(name, default: None, as: None, &blk)
|
|
24
|
-
attributes.update(name => OpenStruct.new(default:, type: as, constraint: blk))
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def attributes = @__attributes__ ||= {}
|
|
28
|
-
|
|
29
|
-
def defaults
|
|
30
|
-
@__defaults__ ||= attributes.inject({}) do |defaults, (name, desc)|
|
|
31
|
-
if desc.default == None
|
|
32
|
-
defaults
|
|
33
|
-
else
|
|
34
|
-
defaults.merge(name => desc.default)
|
|
35
|
-
end
|
|
36
|
-
end.freeze
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def make_callable(&blk)
|
|
40
|
-
@callable = blk
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
# SPDX-License-Identifier: AGPL-3.0-or-later
|