Sha256: 724717ecac1b576a223c22ae819f771eaa3cf67aa5ebd472003436b0c70e6e49

Contents?: true

Size: 484 Bytes

Versions: 5

Compression:

Stored size: 484 Bytes

Contents

require 'ixtlan/optimistic_persistence_module'
require 'dm-core'
module DataMapper

  class StaleResourceError < StandardError; end

end

module Ixtlan   
  module OptimisticPersistence
    
    def self.included(base)
      base.send(:include, ::Ixtlan::OptimisticPersistenceModule)
      base.before :valid? do
        raise ::DataMapper::StaleResourceError.new(model.name + "(#{key}) was stale") if stale?
      end
    end
    ::DataMapper::Model.append_inclusions self
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ixtlan-0.2.4 lib/ixtlan/optimistic_persistence.rb
ixtlan-0.2.3 lib/ixtlan/optimistic_persistence.rb
ixtlan-0.2.2 lib/ixtlan/optimistic_persistence.rb
ixtlan-0.2.1 lib/ixtlan/optimistic_persistence.rb
ixtlan-0.2.0 lib/ixtlan/optimistic_persistence.rb