Module: Oboe::Util
- Defined in:
- lib/oboe/util.rb,
lib/oboe/loading.rb
Defined Under Namespace
Modules: Base64URL
Class Method Summary collapse
-
.method_alias(cls, method, name = nil) ⇒ Object
oboe_alias.
-
.send_include(target_cls, cls) ⇒ Object
oboe_send_include.
Class Method Details
.method_alias(cls, method, name = nil) ⇒ Object
oboe_alias
Centralized utility method to alias a method on an arbitrary class or module.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/oboe/util.rb', line 13 def method_alias(cls, method, name=nil) # Attempt to infer a contextual name if not indicated # # For example: # ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.to_s.split(/::/).last # => "AbstractMysqlAdapter" # begin name ||= cls.to_s.split(/::/).last rescue end if cls.method_defined? method.to_sym or cls.private_method_defined? method.to_sym cls.class_eval do alias_method "#{method}_without_oboe", "#{method}" alias_method "#{method}", "#{method}_with_oboe" end else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument #{name}. Partial traces may occur." end end |
.send_include(target_cls, cls) ⇒ Object
oboe_send_include
Centralized utility method to send a include call for an arbitrary class
39 40 41 42 43 |
# File 'lib/oboe/util.rb', line 39 def send_include(target_cls, cls) if defined?(target_cls) target_cls.send(:include, cls) end end |