Class: Pry::Method::Disowned
- Inherits:
-
Pry::Method
- Object
- Pry::Method
- Pry::Method::Disowned
- Defined in:
- lib/pry/method.rb
Overview
A Disowned Method is one that's been removed from the class on which it was defined.
e.g. class C def foo C.send(:undefine_method, :foo) Pry::Method.from_binding(binding) end end
In this case we assume that the "owner" is the singleton class of the receiver.
This occurs mainly in Sinatra applications.
Instance Attribute Summary (collapse)
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) receiver
readonly
Returns the value of attribute receiver.
Instance Method Summary (collapse)
-
- (Disowned) initialize(*args)
constructor
Create a new Disowned method.
-
- (Object) method_missing(meth_name, *args, &block)
Raise a more useful error message instead of trying to forward to nil.
-
- (Object) owner
Get the hypothesized owner of the method.
-
- (Boolean) undefined?
Is the method undefined? (aka
Disowned).
Methods inherited from Pry::Method
#==, #alias?, all_from_class, all_from_common, all_from_obj, #doc, #doc_for_pry_method, #dynamically_defined?, from_binding, from_class, from_obj, from_str, instance_resolution_order, #is_a?, #method_name_from_first_line, #name_with_owner, #original_name, #pry_doc_info, #pry_method?, resolution_order, #respond_to?, safe_send, #signature, singleton_class, singleton_class_resolution_order, #source, #source_file, #source_line, #source_location, #source_range, #source_type, #super, #super_using_ancestors, #visibility, #wrapped_owner
Methods included from Helpers::DocumentationHelpers
#process_comment_markup, #process_rdoc, #process_yardoc, #process_yardoc_tag, #strip_comments_from_c_code, #strip_leading_hash_and_whitespace_from_ruby_comments, #strip_leading_whitespace
Methods included from RbxMethod
Constructor Details
- (Disowned) initialize(*args)
Create a new Disowned method.
505 506 507 |
# File 'lib/pry/method.rb', line 505 def initialize(*args) @receiver, @name = *args end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(meth_name, *args, &block)
Raise a more useful error message instead of trying to forward to nil.
523 524 525 526 |
# File 'lib/pry/method.rb', line 523 def method_missing(meth_name, *args, &block) raise "Cannot call '#{meth_name}' on an undef'd method." if method(:name).respond_to?(meth_name) Object.instance_method(:method_missing).bind(self).call(meth_name, *args, &block) end |
Instance Attribute Details
- (Object) name (readonly)
Returns the value of attribute name
499 500 501 |
# File 'lib/pry/method.rb', line 499 def name @name end |
- (Object) receiver (readonly)
Returns the value of attribute receiver
499 500 501 |
# File 'lib/pry/method.rb', line 499 def receiver @receiver end |
Instance Method Details
- (Object) owner
Get the hypothesized owner of the method.
518 519 520 |
# File 'lib/pry/method.rb', line 518 def owner class << receiver; self; end end |
- (Boolean) undefined?
Is the method undefined? (aka Disowned)
511 512 513 |
# File 'lib/pry/method.rb', line 511 def undefined? true end |