Skip to content
optimistic find/get on model via updated_at timestamp for datamapper and activerecord
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
MIT-LICENSE
Mavenfile
README.md
Rakefile
ixtlan-optimistic.gemspec

README.md

Ixtlan Optimistic Build Status

it adds optimistic persistence support to DataMapper and ActveRecord usingg the updated_at property/attribute which is automatically updated on any change of the model (for datamapper you need dm-timestamps for that). to load a model use optimistic_get/optimistic_get!/optimistic_find respectively where the first argument is the last updated_at value which the client has. if the client data is uptodate then the optimistic_XYZ method will return the database entity otherwise raise an exception or return nil respectively.

rails setup

automagic via included railtie. just add

`gem 'ixtlan-optimistic'

to your Gemfile.

datamapper

just include Ixtlan::Optimistic::DataMapper to your model:

class User
  include DataMapper::Resource
  include Ixtlan::Optimistic::DataMapper

  property :id, Serial
  property :name, String

  timestamps :at
end

you need timestamps to get to work !

activerecord

just add it with

 ::ActiveRecord::Base.send(:include, 
                           Ixtlan::Optimistic::ActiveRecord)

meta-fu

bug-reports, feature request and pull request are most welcome.

Something went wrong with that request. Please try again.