Sha256: a720eca6580d05a68f58a9a147fa698c5b91ea084fb972721457d9054e4c7c14

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

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

      module ClassMethods

        def purge_all
          FastlyRails.client.purge_by_key(table_key)
        end

        def table_key
          collection_name
        end

        def service_id
          FastlyRails.service_id
        end
      end

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

      def table_key
        self.class.table_key
      end

      def purge
        FastlyRails.client.purge_by_key(record_key)
      end

      def purge_all
        self.class.purge_all
      end

      def service_id
        self.class.service_id
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fastly-rails-0.2.0 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.1.7 lib/fastly-rails/mongoid/surrogate_key.rb