Sha256: d02be52a9208430b182276e3270ede7910670b986f29eccaa198a721d94b9281

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

# Object that follows the observer pattern
# usage:
# Fastly::Purgeable.new(@article).save!
# Fastly::Purgeable.new(@article).destroy!
# This calls save on the @article and then makes a call to fastly to purge from cache
module Fastly
  class Purgeable

    def self.initialize()
    end


    # These methods need to hook into activerecord
    # Calls super
    # Purges the object from the fastly cache
    def destroy
      super
      @queue << self.resource_key
    end

    def destroy!
      super
      Fastly.purge(self.resource_key)
    end

    def save
      super
      Fastly.purge(self.resource_key)
    end

    def save!
      super
      Fastly.purge(self.resource_key)
    end

    def update
      super
      Fastly.purge(self.resource_key)
    end

    # updates all records in the table
    # purge table key
    def update_all
      super
      Fastly.purge(self.table_key)
    end

    def update_attribute
    end

    def update_attributes
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastly-rails-0.1.0 lib/fastly/purgeable.rb