uinit-structure 0.1.2 → 0.1.3

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: 0503a10252f0c6e44bb61a6853d5bc59380dc0b6568e50778d14ba28b0ad0616
4
- data.tar.gz: b3235c878479a28a98d09859bddafbf011f92596c29c59a67f2862e638bb8a44
3
+ metadata.gz: c15895eb9482a3f6f4da9fd7e32cf7faa7b00e8dcc313a88526a1be679532eb2
4
+ data.tar.gz: 4fb76f7c50604b5f1cbd2ff0d245f1586b4e30376f15db6c685e8bea9f427e27
5
5
  SHA512:
6
- metadata.gz: 710a40c77b700bbd2a6a41a3dab9a6144677687f67fa255ac7b8afcdb44a024fb7439e729bc985e2b199f65ac6e8537862ef504669485d05e741e553ad25cf64
7
- data.tar.gz: 1638b06baa9a4929e9bdca10b26056469ec8ad2edcee5e7af21d367cd27834a9986aa4b97dd5329ec73ab3e2628b027e8816505308c5e7e6b892231731724f92
6
+ metadata.gz: 786b0bd30d8855c54271a5a5260459182a5c25a9fe878be6dcc6676822e372eb655980c86a545c5343f736906dc084d9ba11e52ddeee397c4459d65d47aac8e0
7
+ data.tar.gz: 950e1d19b84cdb1101285190c574feb1015fb3b7e9852b6da26bc65e9229272cbc51bbca20f5e2450b51ed72d84ef0ea2cc8bb61410e92cb49822197dd16e096
@@ -6,13 +6,6 @@ module Uinit
6
6
  include Memoizable
7
7
  include Type::Context
8
8
 
9
- def self.scope(&)
10
- context = Class.new { include AttributeContext }.new
11
- context.instance_eval(&)
12
-
13
- context.attributes
14
- end
15
-
16
9
  memo def attributes = []
17
10
 
18
11
  def defaults(**defaults)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Uinit
4
+ module Structure
5
+ class AttributeScope
6
+ include AttributeContext
7
+
8
+ def initialize(context)
9
+ self.context = context
10
+ end
11
+
12
+ def scope(&scope)
13
+ instance_eval(&scope) if scope
14
+
15
+ self
16
+ end
17
+
18
+ def method_missing(name, ...)
19
+ context.send(name, ...)
20
+ end
21
+
22
+ private
23
+
24
+ attr_accessor :context
25
+ end
26
+ end
27
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Uinit
4
4
  module Structure
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
@@ -43,7 +43,7 @@ module Uinit
43
43
  end
44
44
 
45
45
  def struct(&)
46
- attributes = AttributeContext.scope(&)
46
+ attributes = AttributeScope.new(self).scope(&).attributes
47
47
 
48
48
  attributes.each do |attribute|
49
49
  raise NameError, 'Attribute must have a name' unless attribute.name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uinit-structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kimoja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-21 00:00:00.000000000 Z
11
+ date: 2024-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -81,6 +81,7 @@ files:
81
81
  - lib/uinit/structure/attribute_builder.rb
82
82
  - lib/uinit/structure/attribute_context.rb
83
83
  - lib/uinit/structure/attribute_error.rb
84
+ - lib/uinit/structure/attribute_scope.rb
84
85
  - lib/uinit/structure/attribute_type_error.rb
85
86
  - lib/uinit/structure/compilers/as_json.rb
86
87
  - lib/uinit/structure/compilers/attribute.rb