Module: Picombo::Models

Defined in:
lib/core/core.rb

Overview

Model Module

Models are the back end classes that handle business logic and data access. They accept input from controllers, and can manipulate data sources such as databases and other kinds of data.

Creating Model Files

You can use any kind of modeling library to represent your models, such as DataMapper or ActiveRecord. You can also create “raw” models that don’t use a library, and directly access a database. You will need to include your own database access methods in this case

Model Naming Conventions

  • Models live in the Picombo::Models namespace. They must be prefaced with these modules in the file

  • Models are placed in the /models directory

  • Model filenames must be named the same as the class name: class Foobar would live in /models/foobar.rb

  • Model filenames must be lowercase

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

Autoloader for missing models



241
242
243
244
245
246
247
248
249
250
251
# File 'lib/core/core.rb', line 241

def Models.const_missing(name)
	filename = name.to_s

	require 'models/'+filename.downcase.gsub(/_/, '/')

	raise filename+' not found!' if ! const_defined?(name)

	klass = const_get(name)
	return klass if klass
	raise klass+" not found!"
end