Sha256: fc13df3d64278fb0a3d8d39f6d65b27cc600fb6c79fe14d9476457115ff4e50d

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

module Renderful
  class CacheInvalidator
    attr_reader :client

    def initialize(client)
      @client = client
    end

    def process_webhook(body)
      return unless client.cache

      params = body.is_a?(String) ? JSON.parse(body) : body

      client.cache.delete(client.cache_key_for(
                            content_type_id: params['sys']['contentType']['sys']['id'],
                            entry_id: params['sys']['id'],
                          ))

      client.contentful.entries(links_to_entry: params['sys']['id']).each do |linking_entry|
        client.cache.delete(client.cache_key_for(linking_entry))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renderful-0.2.0 lib/renderful/cache_invalidator.rb