Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Example usage of using mince, mince_data_model, and HashyDB in a rails app

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 log
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.md
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
README.md

What Iz This?

This mince rails example application is here to reveal A way to implement the use of the Mince Data Store, Mince, and HashyDB gems.

Mince Some App

Why?

A little background perhaps...

After developing quite a few Rails apps, we started feeling a lot of pain with our models. I'm sure most of us know this pain. We end up having at least one massive model which ends up being the brain model of the application. Generally this model is the User model, or the Project model. Whichever class your application primarily focusses on.

After some time of trying new things and talking to others, reading from others, and evolving our applications, the source of the problem seemed to be the Active Record architecture pattern. Where logic and data are presented as a unified package. The problem with that is that there is a ton of logic that can be associated to a very little bit of data.

The idea behind the mince is to provide the lightest weight ORM possible so that you can build your application's business logic and data logic completely isolated from each other.

One great example is the user model. Every app on the face of the uniwebs has it and we can all relate to it. First, you need to register. Registration has validations. Once you've registered, you need to confirm your email before you can login. Once you login you want to change information about yourself. But since you've already created an account, there are different validations than when you were registering! The validations alone make the User model very complex. You end up with a lot of conditional logic in your user models. After you've implemented registration, your user model has already become over 100 lines long!

What if you could have a separate model for each logical event? A registration model, a password updator model, a user account model? Your validations can become specific to one scenario. With this implementation, every class is less than 100 lines long. Now, number of lines is not our goal, but it is a great indicator to how much that class is doing.

Form more info about the inspiration behind Mince Data Store:

Mince

Mince is a lightweight MongoDB ORM for Ruby. It frees you from using a huge ORM that forces you into using a specific architecture.

@github @rubygems

HashyDB

Provides an interface for storing and retreiving information in a Hash in memory.

The motivation behind this is so you can clone the repository down, have ruby installed, run bundle install and be able to run your tests and develop without being dependent on any other setup.

@github @rubygems

Mince Data Model

Some niceties and defines an implementation to swap out different data persistance strategies. Currently there are 2 supported data persistance strategies: Mince (MongoDB), and HashyDB (in memory hash). If using this gem, all you need to do in order to change the data persistence strategy is to implement the methods outlined by this gem. Check out the Mince Data Store and the HashyDB Data Store for a list of methods to implement.

@github @rubygems

Something went wrong with that request. Please try again.