class Object
Public Instance Methods
instance_exec(*args, &block)
click to toggle source
Evaluate the block with the given arguments within the context of this object, so self is set to the method receiver.
From Mauricio’s eigenclass.org/hiki/bounded+space+instance_exec
This version has been borrowed from Rails for compatibility sake.
# File lib/qed/core_ext.rb, line 19 def instance_exec(*args, &block) begin old_critical, Thread.critical = Thread.critical, true n = 0 n += 1 while respond_to?(method_name = "__instance_exec#{n}") InstanceExecMethods.module_eval { define_method(method_name, &block) } ensure Thread.critical = old_critical end begin send(method_name, *args) ensure InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil end end
must_return(value)
click to toggle source
This is used by the ‘#=>` notation.
# File lib/qed/core_ext.rb, line 40 def must_return(value) assert(self == value, "#{self.inspect} #=> #{value.inspect}") end