Class: CacheBuster::Cloudflare
- Inherits:
-
Object
- Object
- CacheBuster::Cloudflare
- Defined in:
- lib/cache-buster/cloudflare.rb
Instance Method Summary collapse
- #clear(path = 'news') ⇒ Object
-
#initialize ⇒ Cloudflare
constructor
A new instance of Cloudflare.
- #zone ⇒ Object
Constructor Details
#initialize ⇒ Cloudflare
Returns a new instance of Cloudflare.
4 5 6 |
# File 'lib/cache-buster/cloudflare.rb', line 4 def initialize @connection = Rubyflare.connect_with(ENV['CLOUDFLARE_EMAIL'], ENV['CLOUDFLARE_API_KEY']) end |
Instance Method Details
#clear(path = 'news') ⇒ Object
8 9 10 11 12 |
# File 'lib/cache-buster/cloudflare.rb', line 8 def clear(path = 'news') @connection.delete("/zones/#{zone[:id]}/purge_cache", { files: ["#{zone[:host]}/#{path}"] }) end |
#zone ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cache-buster/cloudflare.rb', line 14 def zone @zone ||= begin zone = @connection.get("zones/#{ENV['CLOUDFLARE_ZONE_ID']}") { id: zone.results[:id], host: "http://#{zone.results[:name]}" } end end |