Method: ObjectShadow::MethodIntrospection#method_scope
- Defined in:
- lib/object_shadow/method_introspection.rb
#method_scope(method_name, target: :self) ⇒ Object
Returns the scope of method name given
-
target: must be one of [:self, :class, :instances]
Possible return values: [:public, :protected, :private, nil]
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/object_shadow/method_introspection.rb', line 94 def method_scope(method_name, target: :self) MethodIntrospection.simple_lookup_chain_for(object, target).map{ |lookup_class| if RUBY_VERSION >= "2.6.0" case when lookup_class.public_method_defined?(method_name, true) :public when lookup_class.protected_method_defined?(method_name, true) :protected when lookup_class.private_method_defined?(method_name, true) :private else nil end else case when lookup_class.public_method_defined?(method_name) :public when lookup_class.protected_method_defined?(method_name) :protected when lookup_class.private_method_defined?(method_name) :private else nil end end }.compact.first end |