Skip to content

Commit 5d159f0

Browse files
authored
Merge pull request rails#48004 from byroot/delegate-private
Module#delegate directly define methods as private
2 parents 410d098 + d783979 commit 5d159f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

activesupport/lib/active_support/core_ext/module/delegation.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
193193
method_def = []
194194
method_names = []
195195

196+
method_def << "self.private" if private
197+
196198
methods.each do |method|
197199
method_name = prefix ? "#{method_prefix}#{method}" : method
198200
method_names << method_name.to_sym
@@ -264,7 +266,6 @@ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
264266
end
265267
end
266268
module_eval(method_def.join(";"), file, line)
267-
private(*method_names) if private
268269
method_names
269270
end
270271

0 commit comments

Comments
 (0)