it adds optimistic persistence support to DataMapper and ActveRecord using 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_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.
automagic via included railtie. just add
to your Gemfile.
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 !
just add it with
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request