Sha256: f31cedb2f35826ac7660a216b6a605c59de6bcd6c9007858d4fc1a9e4de27dfe

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

# adds surrogate key instance methods to the models that inherit from activerecord
module FastlyRails
  module SurrogateKey
    extend ActiveSupport::Concern

    included do
      include InstanceMethods
    end

    module ClassMethods

      def purge_all
        FastlyRails.client.purge(table_key)
      end

      def table_key
        table_name
      end

    end

    module InstanceMethods

      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.0 lib/fastly-rails/active_record/surrogate_key.rb