# File lib/sunspot/util.rb, line 280 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
# File lib/sunspot/util.rb, line 259 def id begin @__calling_context__.__send__(:id) rescue ::NoMethodError => e begin @__receiver__.__send__(:id) rescue ::NoMethodError raise(e) end end end
# File lib/sunspot/util.rb, line 276 def method_missing(method, *args, &block) __proxy_method__(method, *args, &block) end
Special case due to `Kernel#sub`‘s existence
# File lib/sunspot/util.rb, line 272 def sub(*args, &block) __proxy_method__(:sub, *args, &block) end
# File lib/sunspot/util.rb, line 236 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
# File lib/sunspot/util.rb, line 255 def initialize(receiver, calling_context) @__receiver__, @__calling_context__ = receiver, calling_context end