Sha256: f0a8f14dac21d5a0ec460ad494cf4308ef5013fa0497da0edd1555f0b0c7fc39

Contents?: true

Size: 579 Bytes

Versions: 5

Compression:

Stored size: 579 Bytes

Contents

module Ixtlan
  module OptimisticPersistenceModule
    def stale?
      if(!new? && prop = properties[:updated_at] && dirty?)
        updated_at = original_attributes[prop] || properties[:updated_at].get!(self)
        qu = {}
        c = model.key_conditions(repository, key)
        c.each {|p,v| qu[p.name] = v}
        
        s = self.model.first(qu)
        if s.nil? 
          false 
        else
          # use to_s to get it to work in both MRI and JRuby
          s.updated_at.to_s != updated_at.to_s
        end
      else
        false
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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