Skip to content
tpitale edited this page Sep 16, 2011 · 3 revisions

Garb creates instances of results using on OpenStruct. If you wish to persist results it is trivial to set Garb to create instances of an object that inherits from ActiveRecord::Base or which includes Datamapper::Model. In fact, any object which takes a hash of attributes in its constructor (new/initialize) will suffice.

To get this behavior, simply set_instance_klass ClassName

class Exits
  include DataMapper::Resource
  extend Garb::Model

  set_instance_klass self

  property :exits, Integer
  property :pageviews, Integer

  metrics :exits, :pageviews
end

Garb now supports symbol operators when using DataMapper with a shim in place. This will likely change when the filtering branch gets merged (or sometime thereafter).

Clone this wiki locally