Skip to content

Commit 677046a

Browse files
committed
Make initialize_copy private
* remove unused macros * call super explicitly with arguments
1 parent 7a537be commit 677046a

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

lib/concurrent/immutable_struct.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def select(&block)
7070
ns_select(&block)
7171
end
7272

73-
# @!macro struct_initialize_copy
74-
#
73+
private
74+
7575
# @!visibility private
7676
def initialize_copy(original)
77-
super
77+
super(original)
7878
ns_initialize_copy
7979
end
8080

lib/concurrent/mutable_struct.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ def select(&block)
169169
synchronize { ns_select(&block) }
170170
end
171171

172-
# @!macro struct_initialize_copy
173-
#
174-
# @!visibility private
175-
def initialize_copy(original)
176-
synchronize do
177-
super
178-
ns_initialize_copy
179-
end
180-
end
181-
182172
# @!macro struct_set
183173
#
184174
# Attribute Assignment
@@ -206,6 +196,16 @@ def []=(member, value)
206196
raise NameError.new("no member '#{member}' in struct")
207197
end
208198

199+
private
200+
201+
# @!visibility private
202+
def initialize_copy(original)
203+
synchronize do
204+
super(original)
205+
ns_initialize_copy
206+
end
207+
end
208+
209209
# @!macro struct_new
210210
def self.new(*args, &block)
211211
clazz_name = nil

lib/concurrent/settable_struct.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ def select(&block)
6969
synchronize { ns_select(&block) }
7070
end
7171

72-
# @!macro struct_initialize_copy
73-
#
74-
# @!visibility private
75-
def initialize_copy(original)
76-
synchronize do
77-
super
78-
ns_initialize_copy
79-
end
80-
end
81-
8272
# @!macro struct_set
8373
#
8474
# @raise [Concurrent::ImmutabilityError] if the given member has already been set
@@ -101,6 +91,16 @@ def []=(member, value)
10191
raise NameError.new("no member '#{member}' in struct")
10292
end
10393

94+
private
95+
96+
# @!visibility private
97+
def initialize_copy(original)
98+
synchronize do
99+
super(original)
100+
ns_initialize_copy
101+
end
102+
end
103+
104104
# @!macro struct_new
105105
def self.new(*args, &block)
106106
clazz_name = nil

lib/concurrent/synchronization/abstract_struct.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ def ns_merge(other, &block)
115115
self.class.new(*self.to_h.merge(other, &block).values)
116116
end
117117

118-
# @!macro struct_initialize_copy
119-
#
120118
# @!visibility private
121119
def ns_initialize_copy
122120
@values = @values.map(&:clone)

0 commit comments

Comments
 (0)