Sha256: eacbff6836bc2ee4eb40bf6773a8a7954859b97b9c0d78ccf69e5572b225408b

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

# Adds surrogate key methods to ActiveRecord models
module FastlyRails
  module SurrogateKey
    extend ActiveSupport::Concern

    module ClassMethods

      def purge_all
        FastlyRails.client.purge(table_key)
      end

      def table_key
        table_name
      end

    end

    def record_key
      "#{table_key}/#{id}"
    end

    def table_key
      self.class.table_key
    end

    def purge
      FastlyRails.client.purge(record_key)
    end

    def purge_all
      self.class.purge_all
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastly-rails-0.1.1 lib/fastly-rails/active_record/surrogate_key.rb