Sha256: 5a9f380f3730dda5dd4c872237f96716b9d3fb81a5940dd9f5cac72312586268

Contents?: true

Size: 472 Bytes

Versions: 5

Compression:

Stored size: 472 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.4.0.pre4 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.0.pre3 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.0.pre2 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.0.pre lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.3.0 lib/ixtlan/optimistic_persistence_validation.rb