<commit_before>require 'active_support'
require 'active_support/core_ext/hash'
require 'active_support/hash_with_indifferent_access'

require 'cachable/version'
require 'cachable/key'

module Cachable
  extend ActiveSupport::Concern

  module ClassMethods
    def find(*attributes)

      cache_key = Key.new(self, attributes)

      Rails.cache.delete(cache_key) if Rails.cache.fetch(cache_key) == []

      Rails.cache.fetch(cache_key) { super(*attributes) }
    end
  end
end
<commit_msg>Updates cache check to check for empty collections not arrays. Related to thebeansgroup/publish#159<commit_after>require 'active_support'
require 'active_support/core_ext/hash'
require 'active_support/hash_with_indifferent_access'

require 'cachable/version'
require 'cachable/key'

module Cachable
  extend ActiveSupport::Concern

  module ClassMethods
    def find(*attributes)

      cache_key = Key.new(self, attributes)

      cached_data = Rails.cache.fetch(cache_key)
      if cached_data.is_a?(ActiveResource::Collection) && cached_data.elements.empty?
        Rails.cache.delete(cache_key)
      end

      Rails.cache.fetch(cache_key) { super(*attributes) }
    end
  end
end

{'fraction_non_alphanumeric': 0.09260832625318606, 'fraction_numerical': 0.002548853016142736, 'mean_word_length': 4.609523809523809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7342190', 'n_tokens_mistral': 378, 'n_tokens_neox': 364, 'n_words': 74}