evt-collection 2.4.2.0 → 2.4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0da4d6ada538145f5de05dbe96dcdf01556f60582f58011a4b0139c421a1db51
4
- data.tar.gz: 8b844dcb8daccc43d829d4a83224818bfd7deff5be41d4ad242544aa7fac14a7
3
+ metadata.gz: 699f42d6306d91f0390b798ca859f6d68ee1df6eb6641dc78dfef84f2db0006b
4
+ data.tar.gz: 3d3c3853ae0b9e7a96d537e6406f4e4c780c6e62e03813c420d657b111e8e62b
5
5
  SHA512:
6
- metadata.gz: d372356ebd516436d3503adabdad726522622afdc0e18ef5afb78d18579aff6315e80debbcf3acc5c85bd6a2ecc49e7c650fe1a1c2e936aaf4e981b7d1406bd3
7
- data.tar.gz: 555f07ebc9e85db79a26e8eaafb9452e78a9964b3a64681a6ff0f84b358695330180193a2a65d3f66b5af46e4aa48506c471f703c108b8cec81c27a52f5d553b
6
+ metadata.gz: '0697d5d3bdc8b40f263b68907d7b75ac7ceaf1f236bed99fb9c4b44424b8aafd51d8d2df695748676a62f7e281f9525b60f0cc18d19e4dc5a03f4615fed8c54e'
7
+ data.tar.gz: 9a959a04cc0421afaea92c179ac087411855438792906bfccd632fa5084908478abd6e075dfc2edffdbea3ddcaae9c510126f7771b264708c4aca391ca474095
@@ -46,13 +46,7 @@ module Collection
46
46
 
47
47
  type_parameter = items[0].class
48
48
 
49
- set = Set[type_parameter].new
50
-
51
- items.each do |member|
52
- set.add(member)
53
- end
54
-
55
- set
49
+ Set[type_parameter].build(items)
56
50
  end
57
51
 
58
52
  def self.Array(items)
@@ -62,12 +56,6 @@ module Collection
62
56
 
63
57
  type_parameter = items[0].class
64
58
 
65
- array = Array[type_parameter].new
66
-
67
- items.each do |member|
68
- array.add(member)
69
- end
70
-
71
- array
59
+ Array[type_parameter].build(items)
72
60
  end
73
61
  end
@@ -11,6 +11,13 @@ module Collection
11
11
 
12
12
  class Member
13
13
  end
14
+
15
+ module Root
16
+ def self.example
17
+ root_class_name = "Class#{SecureRandom.hex(2).upcase}"
18
+ Object.const_set(root_class_name, Class.new)
19
+ end
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -1,11 +1,11 @@
1
1
  module Collection
2
2
  module Generic
3
- def [](type_parameter)
3
+ def [](type_parameter, &implementation)
4
4
  type_parameter_name = constant_name(type_parameter)
5
5
 
6
6
  cls = nil
7
7
  unless self.const_defined?(type_parameter_name, false)
8
- cls = define_class(type_parameter)
8
+ cls = define_class(type_parameter, &implementation)
9
9
  set_collection_constant(type_parameter, cls)
10
10
  else
11
11
  cls = const_get(type_parameter_name)
@@ -14,8 +14,18 @@ module Collection
14
14
  cls
15
15
  end
16
16
 
17
- def define_class(type_parameter)
17
+ def define_class(type_parameter, &implementation)
18
18
  cls = Class.new(self) do
19
+ def self.build(items)
20
+ instance = new
21
+
22
+ items.each do |member|
23
+ instance.add(member)
24
+ end
25
+
26
+ instance
27
+ end
28
+
19
29
  def initialize; end
20
30
 
21
31
  define_method :type_parameter do
@@ -23,6 +33,10 @@ module Collection
23
33
  end
24
34
  end
25
35
 
36
+ if not implementation.nil?
37
+ cls.class_exec(&implementation)
38
+ end
39
+
26
40
  set_collection_constant(type_parameter, cls)
27
41
 
28
42
  cls
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2.0
4
+ version: 2.4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-05 00:00:00.000000000 Z
11
+ date: 2024-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test_bench
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.1.2
60
+ rubygems_version: 3.4.6
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Type-checked set