Class: Cloudflair::PurgeCache

Inherits:
Object
  • Object
show all
Includes:
Communication
Defined in:
lib/cloudflair/api/zone/purge_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Communication

#connection, #hash_to_object, #response

Constructor Details

#initialize(zone_id) ⇒ PurgeCache

Returns a new instance of PurgeCache.



11
12
13
# File 'lib/cloudflair/api/zone/purge_cache.rb', line 11

def initialize(zone_id)
  @zone_id = zone_id
end

Instance Attribute Details

#zone_idObject (readonly)

Returns the value of attribute zone_id.



7
8
9
# File 'lib/cloudflair/api/zone/purge_cache.rb', line 7

def zone_id
  @zone_id
end

Instance Method Details

#everything(purge_everything) ⇒ Object

Parameters:

  • purge_everything

    must be set to true



17
18
19
20
21
# File 'lib/cloudflair/api/zone/purge_cache.rb', line 17

def everything(purge_everything)
  resp = connection.post(path) { |req| req.body = { purge_everything: purge_everything } }
  response resp
  self
end

#pathObject



33
34
35
# File 'lib/cloudflair/api/zone/purge_cache.rb', line 33

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

#selective(cache_identifier = {}) ⇒ Object

Parameters:

  • cache_identifier (Hash) (defaults to: {})

    Consists of :files and :tags, which are String Arrays themselves. Sample: <code>[‘foo.bar/index.htmll’], tags: [‘css’,‘js’]



25
26
27
28
29
30
31
# File 'lib/cloudflair/api/zone/purge_cache.rb', line 25

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