Sha256: 5cd8c19af56c56f46d637e9f1e2a42b15de7a881884bb8e665f0aa631cbc0e55

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
interpret-0.1.5 app/models/interpret/expiration_observer.rb