Sha256: 1b2290fbc83d47c01e7ed9ca7a08e98f83ad82152c9914e769ebf4f8612763e7

Contents?: true

Size: 590 Bytes

Versions: 38

Compression:

Stored size: 590 Bytes

Contents

module Noodall
  module GlobalUpdateTime
    class Stamp
      def self.read
        Rails.cache.read('global_update_time') if defined?(Rails)
      end
  
      def self.update!
        Rails.cache.write('global_update_time', Time.zone.now.utc) if defined?(Rails)
      end
    end
  
    def self.configure(model)
      model.class_eval do
        after_save :global_updated!
        after_destroy :global_updated!
      end
    end
  
    module InstanceMethods
      # Cache the updated time
      def global_updated!
        GlobalUpdateTime::Stamp.update!
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
noodall-core-0.6.3 lib/noodall/global_update_time.rb
noodall-core-0.6.2 lib/noodall/global_update_time.rb
noodall-core-0.6.1 lib/noodall/global_update_time.rb
noodall-core-0.5.7 lib/noodall/global_update_time.rb
noodall-core-0.6.0 lib/noodall/global_update_time.rb
noodall-core-0.5.6 lib/noodall/global_update_time.rb
noodall-core-0.5.5 lib/noodall/global_update_time.rb
noodall-core-0.5.4 lib/noodall/global_update_time.rb
noodall-core-0.5.3 lib/noodall/global_update_time.rb
noodall-core-0.5.1 lib/noodall/global_update_time.rb
noodall-core-0.5.0 lib/noodall/global_update_time.rb
noodall-core-0.4.8 lib/noodall/global_update_time.rb
noodall-core-0.4.7 lib/noodall/global_update_time.rb
noodall-core-0.4.6 lib/noodall/global_update_time.rb
noodall-core-0.4.5 lib/noodall/global_update_time.rb
noodall-core-0.4.3 lib/noodall/global_update_time.rb
noodall-core-0.4.2 lib/noodall/global_update_time.rb
noodall-core-0.4.0 lib/noodall/global_update_time.rb
noodall-core-0.3.12 lib/noodall/global_update_time.rb
noodall-core-0.3.11 lib/noodall/global_update_time.rb