Sha256: b038f21ca76fe44053075a83761c80633bc7508814883a82ab6256a670cd95b5

Contents?: true

Size: 569 Bytes

Versions: 10

Compression:

Stored size: 569 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

10 entries across 10 versions & 1 rubygems

Version Path
ixtlan-0.4.3 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.2 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.1 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0.pre5 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0.pre4 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0.pre3 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0.pre2 lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.4.0.pre lib/ixtlan/optimistic_persistence_module.rb
ixtlan-0.3.0 lib/ixtlan/optimistic_persistence_module.rb