class Sunspot::Util::ContextBoundDelegate

Constants

BASIC_METHODS

Public Class Methods

instance_eval_with_context(receiver, &block) click to toggle source
# File lib/sunspot/util.rb, line 259
def instance_eval_with_context(receiver, &block)
  calling_context = eval('self', block.binding)
  if parent_calling_context = calling_context.instance_eval{@__calling_context__ if defined?(@__calling_context__)}
    calling_context = parent_calling_context
  end
  new(receiver, calling_context).instance_eval(&block)
end
new(receiver, calling_context) click to toggle source
# File lib/sunspot/util.rb, line 278
def initialize(receiver, calling_context)
  @__receiver__, @__calling_context__ = receiver, calling_context
end

Public Instance Methods

__proxy_method__(method, *args, &block) click to toggle source
# File lib/sunspot/util.rb, line 303
def __proxy_method__(method, *args, &block)
  begin
    @__receiver__.__send__(method.to_sym, *args, &block)
  rescue ::NoMethodError => e
    begin
      @__calling_context__.__send__(method.to_sym, *args, &block)
    rescue ::NoMethodError
      raise(e)
    end
  end
end
id() click to toggle source
# File lib/sunspot/util.rb, line 282
def id
  begin
    @__calling_context__.__send__(:id)
  rescue ::NoMethodError => e
    begin
      @__receiver__.__send__(:id)
    rescue ::NoMethodError
      raise(e)
    end
  end
end
method_missing(method, *args, &block) click to toggle source
# File lib/sunspot/util.rb, line 299
def method_missing(method, *args, &block)
  __proxy_method__(method, *args, &block)
end
sub(*args, &block) click to toggle source

Special case due to `Kernel#sub`'s existence

# File lib/sunspot/util.rb, line 295
def sub(*args, &block)
  __proxy_method__(:sub, *args, &block)
end