Sha256: afdbb78d806eeba0af7df1bf58e4739f8f43d571ac03378da717a17eab8f8684

Contents?: true

Size: 775 Bytes

Versions: 7

Compression:

Stored size: 775 Bytes

Contents

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

      module ClassMethods

        def purge_all
          FastlyRails.purge_by_key(table_key)
        end

        def table_key
          collection_name
        end

        def fastly_service_identifier
          FastlyRails.service_id
        end
      end

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

      def table_key
        self.class.table_key
      end

      def purge
        FastlyRails.purge_by_key(record_key)
      end

      def purge_all
        self.class.purge_all
      end

      def fastly_service_identifier
        self.class.fastly_service_identifier
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fastly-rails-0.8.0 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.7.1 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.7.0 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.6.0 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.5.0 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.4.1 lib/fastly-rails/mongoid/surrogate_key.rb
fastly-rails-0.4.0 lib/fastly-rails/mongoid/surrogate_key.rb