Sha256: bda6d9be48a39dd9cfaedc07d4b0ed8dc9c2471f3b97a59e75ebc299031bab27

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

# Adds surrogate key methods to ActiveRecord models
# Purge methods use a POST over PURGE
# The choice of this HTTP method should not effect anything
module FastlyRails
  module ActiveRecord
    module SurrogateKey
      extend ActiveSupport::Concern

      module ClassMethods

        def purge_all
          FastlyRails.client.purge_by_key(table_key)
        end

        def table_key
          table_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/active_record/surrogate_key.rb
fastly-rails-0.1.7 lib/fastly-rails/active_record/surrogate_key.rb