Sha256: 0c61edec43a4eb41d59066f585c0cbc1ffc980e38addbb8f78dbfd46d7f90215

Contents?: true

Size: 565 Bytes

Versions: 6

Compression:

Stored size: 565 Bytes

Contents

module Noodall
  module GlobalUpdateTime
    extend ActiveSupport::Concern

    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

    included do
      after_save :global_updated!
      after_destroy :global_updated!
    end

    module InstanceMethods
      # Cache the updated time
      def global_updated!
        GlobalUpdateTime::Stamp.update!
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
noodall-core-0.8.2 lib/noodall/global_update_time.rb
noodall-core-0.8.1 lib/noodall/global_update_time.rb
noodall-core-0.8.0 lib/noodall/global_update_time.rb
noodall-core-0.7.5 lib/noodall/global_update_time.rb
noodall-core-0.7.3 lib/noodall/global_update_time.rb
noodall-core-0.7.2 lib/noodall/global_update_time.rb