Sha256: d2d8db619e39fca805f62992354da4c792b345ae3e51138eb9acea32bd73604c

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

# Adds surrogate key methods to ActiveRecord models
module FastlyRails
  module ActiveRecord
    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
end

Version data entries

1 entries across 1 versions & 1 rubygems

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