<commit_before>require_relative './attribute_specification'
require_relative './attribute_http_client'
require_relative './attribute_lookup'
require_relative './storage/storage_entry'

module ApiCachedAttributes
  # Our humble lookup service
  class AttributeMethodResolver
    attr_reader :key_prefix, :attributes
    attr_accessor :db_cache

    def initialize(base_class, options)
      @base_class = base_class
      @options = options
      @db_cache = nil
      @attributes = create_attributes!
    end

    def get(method, scope, named_resource = :default, target_instance)
      attribute = get_attribute_in_scope(method, scope)

      attr_lookup = ApiCachedAttributes.lookup_method
      attr = attr_lookup.find(attribute)
      attr.value
    end

    private

    def create_attributes!
      @base_class.cached_attributes.map do |method, value|
        AttributeSpecification.new(method, @base_class)
      end
    end

    def get_attribute(name)
      @attributes.detect { |attr| attr.name == name }
    end

    def get_attribute_in_scope(name, scope)
      attr = get_attribute(name)
      attr.client_scope = scope
      attr
    end
  end
end
<commit_msg>remove unused db_cache<commit_after>require_relative './attribute_specification'
require_relative './attribute_http_client'
require_relative './attribute_lookup'
require_relative './storage/storage_entry'

module ApiCachedAttributes
  # Our humble lookup service
  class AttributeMethodResolver
    attr_reader :key_prefix, :attributes

    def initialize(base_class, options)
      @base_class = base_class
      @options = options
      @attributes = create_attributes!
    end

    def get(method, scope, named_resource = :default, target_instance)
      attribute = get_attribute_in_scope(method, scope)

      attr_lookup = ApiCachedAttributes.lookup_method
      attr = attr_lookup.find(attribute)
      attr.value
    end

    private

    def create_attributes!
      @base_class.cached_attributes.map do |method, value|
        AttributeSpecification.new(method, @base_class)
      end
    end

    def get_attribute(name)
      @attributes.detect { |attr| attr.name == name }
    end

    def get_attribute_in_scope(name, scope)
      attr = get_attribute(name)
      attr.client_scope = scope
      attr
    end
  end
end

{'fraction_non_alphanumeric': 0.07325530992631123, 'fraction_numerical': 0.0, 'mean_word_length': 3.421455938697318, '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': '4437141', 'n_tokens_mistral': 663, 'n_tokens_neox': 650, 'n_words': 152}