protected_method_defined?

mod.protected_method_defined?(symbol) â true or false
Instance Public methods

Returns true if the named protected method is defined by mod (or its included modules and, if mod is a class, its ancestors).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module A
  def method1()  end
end
class B
  protected
  def method2()  end
end
class C < B
  include A
  def method3()  end
end
 
A.method_defined? :method1              #=> true
C.protected_method_defined? "method1"   #=> false
C.protected_method_defined? "method2"   #=> true
C.method_defined? "method2"             #=> true
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.