File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
lib/concurrent/synchronization Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,12 @@ class ImmutableStruct < Synchronization::Object
11
11
def self . with_fields ( *names , &block )
12
12
Class . new ( self ) do
13
13
attr_reader ( *names )
14
-
14
+ const_set :MEMBERS , names
15
15
class_eval <<-RUBY , __FILE__ , __LINE__ + 1
16
16
def initialize(#{ names . join ( ', ' ) } )
17
17
#{ names . map { |n | '@' + n . to_s } . join ( ', ' ) } = #{ names . join ( ', ' ) }
18
18
ensure_ivar_visibility!
19
19
end
20
-
21
- def members
22
- #{ names . inspect }
23
- end
24
-
25
- def self.members
26
- #{ names . inspect }
27
- end
28
20
RUBY
29
21
30
22
instance_eval &block if block
@@ -46,6 +38,14 @@ def self.[](*args)
46
38
new *args
47
39
end
48
40
41
+ def self . members
42
+ MEMBERS
43
+ end
44
+
45
+ def members
46
+ MEMBERS
47
+ end
48
+
49
49
include Enumerable
50
50
51
51
def each ( &block )
You can’t perform that action at this time.
0 commit comments