lib/utopia/controller.rb
def load_controller_file(uri_path)
			base_path = File.join(@root, uri_path.components)
			
			controller_path = File.join(base_path, CONTROLLER_RB)
			# puts "load_controller_file(#{path.inspect}) => #{controller_path}"
			
			if File.exist?(controller_path)
				klass = Class.new(@base)
				
				# base_path is expected to be a string representing a filesystem path:
				klass.const_set(:BASE_PATH, base_path.freeze)
				
				# uri_path is expected to be an instance of Path:
				klass.const_set(:URI_PATH, uri_path.dup.freeze)
				
				klass.const_set(:CONTROLLER, self)
				
				klass.class_eval(File.read(controller_path), controller_path)
				
				# We lock down the controller class to prevent unsafe modifications:
				klass.freeze
				
				# Create an instance of the controller:
				return klass.new
			else
				return nil
			end
		end
# Loads the controller file for the given relative url_path.
Loads the controller file for the given relative url_path.
Loads the controller file for the given relative url_path .
def load_controller_file(uri_path)
			base_path = File.join(@root, uri_path.components)
			controller_path = File.join(base_path, CONTROLLER_RB)
			if File.exist?(controller_path)
				klass = Class.new(@base)
				klass.const_set(:BASE_PATH, base_path.freeze)
				klass.const_set(:URI_PATH, uri_path.dup.freeze)
				klass.const_set(:CONTROLLER, self)
				klass.class_eval(File.read(controller_path), controller_path)
				klass.freeze
				return klass.new
			else
				return nil
			end
		end
def load_controller_file ( uri_path ) base_path = File . join ( @root , uri_path . components ) controller_path = File . join ( base_path , CONTROLLER_RB ) if File . exist? ( controller_path ) klass = Class . new ( @base ) klass . const_set ( :BASE_PATH , base_path . freeze ) klass . const_set ( :URI_PATH , uri_path . dup . freeze ) klass . const_set ( :CONTROLLER , self ) klass . class_eval ( File . read ( controller_path ) , controller_path ) klass . freeze return klass . new else return nil end end
Loads the controller file for the given relative url_path.
Loads the controller file for the given relative url_path .
# puts "load_controller_file(#{path.inspect}) => #{controller_path}" # base_path is expected to be a string representing a filesystem path: # uri_path is expected to be an instance of Path: # We lock down the controller class to prevent unsafe modifications: # Create an instance of the controller:
uri_path