Sha256: 9e74cd9196e8d20f5688d333cf6156915f1bae7b8d71e477d872b99e792bf047
Contents?: true
Size: 523 Bytes
Versions: 4
Compression:
Stored size: 523 Bytes
Contents
module Ohm module Versioned def self.included(model) model.attribute :_version, lambda { |x| x.to_i } end def save current_version = new? ? 0 : redis.call("HGET", key, :_version).to_i if current_version != _version raise Ohm::VersionConflict.new(attributes) end self._version = current_version + 1 super end end class VersionConflict < StandardError attr :attributes def initialize(attributes) @attributes = attributes end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ohm-contrib-2.0.0.alpha5 | lib/ohm/versioned.rb |
ohm-contrib-2.0.0.alpha4 | lib/ohm/versioned.rb |
ohm-contrib-2.0.0.alpha3 | lib/ohm/versioned.rb |
ohm-contrib-2.0.0.alpha2 | lib/ohm/versioned.rb |