Sha256: bf96010ee750c26d89493bf2b1cbd2cbb5c776cf705ff7b025805d7ecce3dd55

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 Bytes

Contents

require 'cloudflair/communication'

module Cloudflair
  class PurgeCache
    attr_reader :zone_id

    include Cloudflair::Communication

    def initialize(zone_id)
      @zone_id = zone_id
    end

    ##
    # @param purge_everything must be set to true
    def everything(purge_everything)
      resp = connection.post(path) { |req| req.body = { purge_everything: purge_everything } }
      response resp
      self
    end

    ##
    # @param [Hash] cache_identifier Consists of :files and :tags, which are String Arrays themselves. Sample: <code>{files: ['https://foo.bar/index.htmll'], tags: ['css','js']}
    def selective(cache_identifier = {})
      return self if cache_identifier.nil? || cache_identifier.empty?

      resp = connection.post(path) { |req| req.body = cache_identifier }
      response resp
      self
    end

    def path
      "zones/#{zone_id}/purge_cache"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudflair-0.2.5 lib/cloudflair/api/zone/purge_cache.rb
cloudflair-0.2.4 lib/cloudflair/api/zone/purge_cache.rb