<commit_before>require 'active_support/core_ext/class/attribute'
module Oat
  class Serializer

    class_attribute :_adapter

    def self.schema(&block)
      @schema = block if block_given?
      @schema || Proc.new{}
    end

    def self.adapter(adapter_class = nil)
      self._adapter = adapter_class if adapter_class
      self._adapter
    end

    attr_reader :item, :context, :adapter_class, :adapter

    def initialize(item, context = nil, _adapter_class = nil, parent_serializer = nil)
      @item, @context = item, context
      @parent_serializer = parent_serializer
      @adapter_class = _adapter_class || self.class.adapter
      @adapter = @adapter_class.new(self)
    end

    def top
      @top ||= @parent_serializer || self
    end

    def method_missing(name, *args, &block)
      if adapter.respond_to?(name)
        adapter.send(name, *args, &block)
      else
        super
      end
    end<commit_msg>Missing adapter methods are logged instead of raised.<commit_after>require 'active_support/core_ext/class/attribute'
module Oat
  class Serializer

    class_attribute :_adapter, :logger

    def self.schema(&block)
      @schema = block if block_given?
      @schema || Proc.new{}
    end

    def self.adapter(adapter_class = nil)
      self._adapter = adapter_class if adapter_class
      self._adapter
    end

    def self.warn(msg)
      logger ? logger.warning(msg) : puts(msg)
    end

    attr_reader :item, :context, :adapter_class, :adapter

    def initialize(item, context = nil, _adapter_class = nil, parent_serializer = nil)
      @item, @context = item, context
      @parent_serializer = parent_serializer
      @adapter_class = _adapter_class || self.class.adapter
      @adapter = @adapter_class.new(self)
    end

    def top
      @top ||= @parent_serializer || self
    end

    def method_missing(name, *args, &block)
      if adapter.respond_to?(name)
        adapter.send(name, *args, &block)
      else
        self.class.warn "[#{adapter.class}] does not implement ##{name}. Called with #{args}"
      end
    end
{'fraction_non_alphanumeric': 0.09893822393822393, 'fraction_numerical': 0.0, 'mean_word_length': 2.9187145557655954, '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': '730566', 'n_tokens_mistral': 634, 'n_tokens_neox': 616, 'n_words': 161}