Sha256: 15db63090080d5cc5a549c651d78c087f80af2f8ad005e5116ca147e1ab13b54

Contents?: true

Size: 593 Bytes

Versions: 8

Compression:

Stored size: 593 Bytes

Contents

module Interpret

  class ExpirationObserver < ActiveRecord::Observer
    observe Interpret::Translation

    def after_update(record)
      run_expiration(record) if record.value_changed?
    end

    def after_create(record)
      run_expiration(record)
    end

    def after_destroy(record)
      run_expiration(record)
    end

  protected
    # expiration logic for your app
    def expire_cache(key)
    end

    def expire_cache_all
    end

  private
    def run_expiration(record)
      Interpret.backend.reload! if Interpret.backend
      expire_cache(record.key)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
interpret-1.1.2 app/models/interpret/expiration_observer.rb
interpret-1.1.1 app/models/interpret/expiration_observer.rb
interpret-1.1.0 app/models/interpret/expiration_observer.rb
interpret-1.0.2 app/models/interpret/expiration_observer.rb
interpret-1.0.1 app/models/interpret/expiration_observer.rb
interpret-0.2.1 app/models/interpret/expiration_observer.rb
interpret-1.0.0 app/models/interpret/expiration_observer.rb
interpret-0.2.0 app/models/interpret/expiration_observer.rb