Skip to content
Philip (flip) Kromer edited this page Apr 25, 2012 · 3 revisions

Overview

We provide three general flavors of model:

  • Gorillib::Record: lightweight assembly of a structured record: define softly-typed properties

    • default values
    • typecasting
  • Gorillib::Model: full-featured structured models

  • Gorillib::Builder: DSL-style getset methods:

    dataflow :web_logs do stage :

Goals

  • light, predictable magic

  • writing might be magical, but the resulting record never is. In the typical case, you have objects with attr_accessors

  • compatible with Avro terminology & conceptual model

  • upwards compatible with ActiveSupport / ActiveModel

Why the hell, in a world with ActiveRecord, Datamapper, Hashie, Struct, ..., do we need yet another damn model framework?

ActiveRecord and Datamapper excel in a world where data (and truth) live in the database. ActiveRecord sets the standard for elegant magic, but is fairly heavyweight -- it's often overkill for the myriad flyweight scripts, Goliath apps, and such that we deploy. Datamapper does a remarkable job of delivering power while still being light on its toes, but ultimately is too tightly bound to an ORM view of the world. Hashie, Structs and OStructs are, in my experience, too generous, and their use leads to mealymouthed code.

More importantly, our data spends most of its time on the wire or being handled as an opaque blob of data; a good amount of time being handled as a generic bundle of properties; and (though most important) a relatively small amount of time as an active, assertive object. So type conversion and validation are fundamental actions, but shouldn't crud up my critical path or be required. My models should offer predictable and disciplined features, but I should be able to access them as generic bags of facts.

Clone this wiki locally