Initial model magic code.

This code is the initial relationship building code for sets, it creates the set model and
builds the relationships about the involved models.

Parent 1:N Set N:N Child

The Set/Child relationship is build a regular many-to-many relationship with Rails, the Parent/Set relationship is built using belongs_to, that is, the parent has to have an FK to the newly generated Set class.

This code assumes can't be run as-is unless you have the migrations and parent/child models ready, generators do not exist yet so this has to be done by hand. The SQL code to handle the Sets behind the curtains is not there yet as well, this is just the magic relationship code.
Added a generator for the sets migration.

Sets need two parameters, the parent table and the child (related) table. What this
migration will create is the set table, a regular many-to-many relationship table between
the set table and the child table, and will add a column to relate the parent column to
the set table hence creating the full many-to-many relationship. Indexes are added for
all relationship columns (foreign keys).
Fixed a bug with the migration generation.

Some references to the child table where not being properly tableize'd. Also added a
Migration to the migration class name just to avoid collisions.
Fixed a bug in the naming convention of the generated migrations.

Made the references in the set relationship table not nullable.
Simplified the call to has_many_with_set.

It originally required both the parent and the child but was redundant because the parent
name is already available at that point in self. Also simplified the relationship building
code a little bit.
Added methods to build the set finding queries.

To find an appropriate set for a given relationship we need to queries, one to find
empty sets and another one to find populated sets. The methods added generate these
queries using the model names.
Added methods to the model to get and set its items.

In order to make it easy for developers to access their sets we expose an array that will
be used at save time to generate (or find) the matching set. The array is named after the
child relationship. (ej, article.tags).
Added preloading of sets.

Changed the getter to not load the data from the database to fill up the instance
variable holding the set items it is now preloaded when model instances are created.
Added set saving.

Added a before_save callback to catch when the parent model is being saved to find or
create a suitable set, the callback also handles saving of child models that may be new
that have been related to the parent.
Fixed a saving bug when the local value of the set items may be null.
Fixing the value of the items when setting them directly.

When setting the set items variable nil will be converted to an empty array and
if a single item is passed it will be wrapped inside an array.
Fixed a bug with indexes names.

Since the set related table names can be large, generated names for indexes by Rails
can break the 63, 64 name limit in some databases, if they are larger than 63, they will get trimmed.
Setter method for set items is a bit smarter.

The behavior is a bit more smarter to work nicely with Rails ORM operations. If an
element is set that is not an array but can be converted (like ActiveRecord::Relation
which is what .where() returns) it will be converted. If not an Array and cannot be
converted, then it will be wrapped inside an array and hope for the best.
Changed the name convention so there won't be any clashes.

Originally the names of the set tables depended only on the child table, this would cause problems
if another set was created in another parent but with the same child.
Changed the Relationships module to be used stand alone, not included. Code is not needed all the time.
First version of the README file, still incomplete but it conveys purpose and intent.
README file is complete.
Added a flatten in the saving code.

This is just to make sure we do not have internal arrays in our values array if people use << to append things into the items.
Improved the README file.

Changed the examples and added a bit more explanation.
Wrapped the set saving code inside transactions.

They have to be inside a transaction because sets have to be unique, the query that
tries to find a set has to be in the same transaction as the one that saves it because
we may get into a race condition where the same set may be created twice.