Module: MethodSource::MethodExtensions
- Included in:
- Method, Proc, UnboundMethod
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/lib/method_source.rb
Overview
This module is to be included by ‘Method` and `UnboundMethod` and provides the `#source` functionality
Class Method Summary collapse
-
.included(klass) ⇒ Object
We use the included hook to patch Method#source on rubinius.
Instance Method Summary collapse
-
#comment ⇒ String
Return the comments associated with the method as a string.
-
#source ⇒ String
Return the sourcecode for the method as a string.
Class Method Details
.included(klass) ⇒ Object
We use the included hook to patch Method#source on rubinius. We need to use the included hook as Rubinius defines a ‘source` on Method so including a module will have no effect (as it’s higher up the MRO).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/lib/method_source.rb', line 79 def self.included(klass) if klass.method_defined?(:source) && Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ klass.class_eval do orig_source = instance_method(:source) define_method(:source) do begin super rescue orig_source.bind(self).call end end end end end |
Instance Method Details
#comment ⇒ String
Return the comments associated with the method as a string.
121 122 123 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/lib/method_source.rb', line 121 def comment MethodSource.comment_helper(source_location, defined?(name) ? name : inspect) end |
#source ⇒ String
Return the sourcecode for the method as a string
109 110 111 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/lib/method_source.rb', line 109 def source MethodSource.source_helper(source_location, defined?(name) ? name : inspect) end |