52 lines
782 B
Plaintext
52 lines
782 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,ruby]
|
|
----
|
|
class A
|
|
def mymethod
|
|
puts "I got called"
|
|
end
|
|
private :mymethod
|
|
end
|
|
|
|
a = A.new()
|
|
# => false
|
|
puts a.respond_to?(:mymethod)
|
|
|
|
class << a
|
|
public :mymethod # NonCompliant: method was private
|
|
end
|
|
# => true
|
|
puts a.respond_to?(:mymethod)
|
|
|
|
b = A.new()
|
|
# => false
|
|
puts b.respond_to?(:mymethod)
|
|
|
|
A.class_eval do
|
|
public :mymethod # NonCompliant: method was private
|
|
end
|
|
|
|
c = A.new()
|
|
# => true
|
|
puts c.respond_to?(:mymethod)
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|