ActiveRecordLite is an object-relational mapping system inspired by ActiveRecord. Uses Ruby's metaprogramming capabilities to implement its core functionality.
SQLObject::find(id)
returns a SQLObject with attributes matching the database row having the corresponding idSQLObject#insert
creates new row in the database with the SQLObject's attributes and assigns an idSQLObject#update
maps current attribute values over previous column values in the database on the row with the corresponding idSQLObject#save
inserts or updates SQLObject based onid.nil?
SQLObject#where(params)
forms and executes SQL query based on params; returns an array of SQLObjectsSQLObject#belongs_to(name, options)
defines a method,name
, that returns a SQLObject whose#model_name
and:primary_key
value correspond to the:class_name
option and:foreign_key
value of the associationSQLObject#has_many(name, options)
is the inverse of#belongs_to
; defines a method,name
that returns an array of SQLObjects with appropriate#model_name
s and:primary_key
valuesSQLObject#has_one_through(name, through_name, source_name)
defines a relationship between two SQLObjects through two#belongs_to
relationships. Defines a method,name
, that returns a SQLObject whose#model_name
corresponds to thesource_name
- Add this repo to your project
- Require
'active_record_lite'