/ARLite

Active Record lite, rebuilt using metaprogramming.

Primary LanguageRuby

Active Record Lite

This project contains the basics of Active Record functionality. Metaprogramming is used in order to redefine common AR features:

  • attr_accessible and attr_accessor
  • Initial table setup
  • Common SQL queries, such as:
    • Find by id
    • Find all
    • Update record
    • Create new record
    • Save
  • BelongsTo and HasMany associations
  • HasOneThrough

SQL queries are written using Heredocs, leveraging string interpolation to handle a variable number of inputs into the queries. Methods and instance variables are setup through the use of ::send and ::define_method.