vendor/bundle/ruby/2.3.0/gems/sqreen-1.10.5/lib/sqreen/instrumentation.rb
# Override a singleton method on an instance
Override a singleton method on an instance
Override a singleton method on an instance
def override_singleton_method(instance, klass_name, meth)
      saved_meth_name = get_saved_method_name(meth, 'singleton')
      if instance.respond_to?(saved_meth_name, true)
        Sqreen.log.debug { "#{saved_meth_name} found #{instance.class}##{instance.object_id} already instrumented" }
        return nil
      elsif instance.frozen?
        Sqreen.log.debug { "#{instance.class}##{instance.object_id} is frozen, not reinstrumenting" }
        return nil
      end
      raise Sqreen::NotImplementedYet, "#{instance.inspect} doesn't respond to define_singleton_method" unless instance.respond_to?(:define_singleton_method)
      p = Instrumentation.define_callback_method(meth, saved_meth_name,
                                                 klass_name)
      instance.define_singleton_method(saved_meth_name, instance.method(meth))
      instance.define_singleton_method(meth, p)
      eval <<-RUBY, binding, __FILE__, __LINE__ + 1
      class << instance
        private :#{saved_meth_name}
      end
      saved_meth_name
      RUBY
    end
def override_singleton_method ( instance , klass_name , meth ) saved_meth_name = get_saved_method_name ( meth , 'singleton' ) if instance . respond_to? ( saved_meth_name , true ) Sqreen . log . debug { "#{saved_meth_name} found #{instance.class}##{instance.object_id} already instrumented" } return nil elsif instance . frozen? Sqreen . log . debug { "#{instance.class}##{instance.object_id} is frozen, not reinstrumenting" } return nil end raise Sqreen :: NotImplementedYet , "#{instance.inspect} doesn't respond to define_singleton_method" unless instance . respond_to? ( :define_singleton_method ) p = Instrumentation . define_callback_method ( meth , saved_meth_name , klass_name ) instance . define_singleton_method ( saved_meth_name , instance . method ( meth ) ) instance . define_singleton_method ( meth , p ) eval <<-RUBY , binding , __FILE__ , __LINE__ + 1 
      class << instance
        private : #{ saved_meth_name } 
      end
      saved_meth_name
       RUBY end
Override a singleton method on an instance
Override a singleton method on an instance
# Hide saved method (its only available in this syntax)
instance
<not_specific>
klass_name
<not_specific>
meth
<not_specific>