Skip to content

Commit bffe05f

Browse files
committed
Module#delegate stop accepting the private as: parameter
The feature remains usable internally, but via `ActiveSupport::Delegation`, this way we don't allow third party use.
1 parent 6ee0041 commit bffe05f

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

actioncable/lib/action_cable/channel/broadcasting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def serialize_broadcasting(object) # :nodoc:
3535
end
3636
end
3737

38-
delegate :broadcasting_for, :broadcast_to, to: :class, as: ClassMethods
38+
ActiveSupport::Delegation.generate(self, [:broadcasting_for, :broadcast_to], to: :class, as: ClassMethods)
3939
end
4040
end
4141
end

actioncable/lib/action_cable/channel/naming.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def channel_name
1818
end
1919
end
2020

21-
delegate :channel_name, to: :class, as: ClassMethods
21+
ActiveSupport::Delegation.generate(self, [:channel_name], to: :class, as: ClassMethods)
2222
end
2323
end
2424
end

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Module
157157
# Foo.new("Bar").name # raises NoMethodError: undefined method `name'
158158
#
159159
# The target method must be public, otherwise it will raise +NoMethodError+.
160-
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil, as: nil)
160+
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
161161
::ActiveSupport::Delegation.generate(
162162
self,
163163
methods,
@@ -166,7 +166,6 @@ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil, as: n
166166
prefix: prefix,
167167
allow_nil: allow_nil,
168168
private: private,
169-
as: as,
170169
)
171170
end
172171

activesupport/lib/active_support/current_attributes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def attribute(*names, default: nil)
132132
end
133133
end
134134

135-
singleton_class.delegate(*names.flat_map { |name| [name, "#{name}="] }, to: :instance, as: self)
135+
Delegation.generate(singleton_class, names.flat_map { |name| [name, "#{name}="] }, to: :instance, as: self)
136136

137137
self.defaults = defaults.merge(names.index_with { default })
138138
end
@@ -184,7 +184,7 @@ def method_added(name)
184184
return if name == :initialize
185185
return unless public_method_defined?(name)
186186
return if respond_to?(name, true)
187-
singleton_class.delegate(name, to: :instance, as: self)
187+
Delegation.generate(singleton_class, [name], to: :instance, as: self)
188188
end
189189
end
190190

activesupport/lib/active_support/duration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def calculate_total_seconds(parts)
221221
end
222222
end
223223

224-
delegate :to_f, :positive?, :negative?, :zero?, :abs, to: :@value, as: Integer
224+
Delegation.generate(self, [:to_f, :positive?, :negative?, :zero?, :abs], to: :@value, as: Integer)
225225

226226
def initialize(value, parts, variable = nil) # :nodoc:
227227
@value, @parts = value, parts

0 commit comments

Comments
 (0)