UtopiaSourceUtopiaControllerVariables

class Variables

Provides a stack-based instance variable lookup mechanism. It can flatten a stack of controllers into a single hash.

Definitions

def fetch(key, default=self)

We use self as a seninel

Implementation

def fetch(key, default=self)
	if controller = self.top
		if controller.instance_variables.include?(key)
			return controller.instance_variable_get(key)
		end
	end
	
	if block_given?
		yield(key)
	elsif !default.equal?(self)
		return default
	else
		raise KeyError.new(key)
	end
end