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.
This commit is contained in:
parent
6ee0041ed2
commit
bffe05f246
@ -35,7 +35,7 @@ def serialize_broadcasting(object) # :nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
delegate :broadcasting_for, :broadcast_to, to: :class, as: ClassMethods
|
||||
ActiveSupport::Delegation.generate(self, [:broadcasting_for, :broadcast_to], to: :class, as: ClassMethods)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ def channel_name
|
||||
end
|
||||
end
|
||||
|
||||
delegate :channel_name, to: :class, as: ClassMethods
|
||||
ActiveSupport::Delegation.generate(self, [:channel_name], to: :class, as: ClassMethods)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -157,7 +157,7 @@ class Module
|
||||
# Foo.new("Bar").name # raises NoMethodError: undefined method `name'
|
||||
#
|
||||
# The target method must be public, otherwise it will raise +NoMethodError+.
|
||||
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil, as: nil)
|
||||
def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
|
||||
::ActiveSupport::Delegation.generate(
|
||||
self,
|
||||
methods,
|
||||
@ -166,7 +166,6 @@ def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil, as: n
|
||||
prefix: prefix,
|
||||
allow_nil: allow_nil,
|
||||
private: private,
|
||||
as: as,
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -132,7 +132,7 @@ def attribute(*names, default: nil)
|
||||
end
|
||||
end
|
||||
|
||||
singleton_class.delegate(*names.flat_map { |name| [name, "#{name}="] }, to: :instance, as: self)
|
||||
Delegation.generate(singleton_class, names.flat_map { |name| [name, "#{name}="] }, to: :instance, as: self)
|
||||
|
||||
self.defaults = defaults.merge(names.index_with { default })
|
||||
end
|
||||
@ -184,7 +184,7 @@ def method_added(name)
|
||||
return if name == :initialize
|
||||
return unless public_method_defined?(name)
|
||||
return if respond_to?(name, true)
|
||||
singleton_class.delegate(name, to: :instance, as: self)
|
||||
Delegation.generate(singleton_class, [name], to: :instance, as: self)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -221,7 +221,7 @@ def calculate_total_seconds(parts)
|
||||
end
|
||||
end
|
||||
|
||||
delegate :to_f, :positive?, :negative?, :zero?, :abs, to: :@value, as: Integer
|
||||
Delegation.generate(self, [:to_f, :positive?, :negative?, :zero?, :abs], to: :@value, as: Integer)
|
||||
|
||||
def initialize(value, parts, variable = nil) # :nodoc:
|
||||
@value, @parts = value, parts
|
||||
|
Loading…
Reference in New Issue
Block a user