Sha256: 7232ec26057b9c430a3153d25ae69ac2e905cb925569a2a99da08b603f125aba

Contents?: true

Size: 479 Bytes

Versions: 5

Compression:

Stored size: 479 Bytes

Contents

require 'ixtlan/optimistic_persistence_module'

module DataMapper

  class StaleResource < StandardError; end
   
  module OptimisticPersistenceValidation
    
    def self.included(base)
      base.send(:include, ::Ixtlan::OptimisticPersistenceModule)
      base.validates_with_block :stale do
        if(stale?)
          [false, "stale resource, please reload the resource"]
        else
          true
        end
      end
    end
    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_validation.rb
ixtlan-0.2.3 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.2.2 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.2.1 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.2.0 lib/ixtlan/optimistic_persistence_validation.rb