Sha256: a23b9d4f2280656d2205f5ec47dad654a066f32a6e6253a5263fb04d22349fda

Contents?: true

Size: 462 Bytes

Versions: 5

Compression:

Stored size: 462 Bytes

Contents

require 'ixtlan/optimistic_persistence_module'
require 'ixtlan/stale_resource_error'

module Ixtlan

  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.3 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.2 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.1 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.0 lib/ixtlan/optimistic_persistence_validation.rb
ixtlan-0.4.0.pre5 lib/ixtlan/optimistic_persistence_validation.rb