DynamicBase is a lightweight object-relational mapping tool built with Ruby. By creating a subclass of the
Base class, existing tables in the database are mapped to these new classes.
Using the sample database as an example, one can retrieve the NYC attractions in the Bronx by running
Borough.first.sights. To change a property, for example the name, one can simply type
bronx = Borough.first bronx.name = 'The Bronx' bronx.save
Will return an array of all entries in the database for the specified table.
Will return the first database entry for the specified table (ordered by id).
Will return the last database entry for the specified table (ordered by id).
Will return the entry in the database with the id matching the argument.
Creates a new Base object (which can be modified and then update or insert intothe database with the save method below)
Depending on if entry exists in database, will either update or insert into database.
borough = Borough.new borough.name = "Queens" borough.save
Returns the results of a SQL query based on the hash parameters passed in as arguments.
Will return base object with the child associated with the selected object.
Will return base object with the parent associated with the selected object.
Will return base object with the grandparent associated with the selected object.
A sample database is included. To run simply clone this repo and open with pry or IRB with the
load 'demo/nyc.rb' command.