<commit_before>require 'active_support/core_ext/hash'

module SimpleJsonSDKBuilder
module Resource

  def self.included(klass)
    klass.class_eval do
      include ActiveModel::Serializers::JSON
    end

    klass.extend ClassMethods
  end

  def initialize(attrs = {})
    @attributes = (attrs || {}).with_indifferent_access
  end

  def attributes
    @attributes
  end

  def attributes=(attributes)
    self.class.simple_json_attributes.each do |attr|
      self.send("#{attr}=", attributes[attr])
    end
  end

  private

  module ClassMethods

    def simple_json_attribute(*attrs)
      attrs.each do |attr|
        attr = attr.to_s
        simple_json_attributes.push(attr)
        define_method attr do
          @attributes[attr]
        end
        define_method "#{attr}=" do |value|
          @attributes[attr] = value
        end
      end
    end

    def simple_json_attributes
      @simple_json_attributes ||= []
    end

  end

end
end
<commit_msg>setting "include_root_in_json" to false by default<commit_after>require 'active_support/core_ext/hash'

module SimpleJsonSDKBuilder
module Resource

  def self.included(klass)
    klass.class_eval do
      include ActiveModel::Serializers::JSON
      self.include_root_in_json = false
    end

    klass.extend ClassMethods
  end

  def initialize(attrs = {})
    @attributes = (attrs || {}).with_indifferent_access
  end

  def attributes
    @attributes
  end

  def attributes=(attributes)
    self.class.simple_json_attributes.each do |attr|
      self.send("#{attr}=", attributes[attr])
    end
  end

  private

  module ClassMethods

    def simple_json_attribute(*attrs)
      attrs.each do |attr|
        attr = attr.to_s
        simple_json_attributes.push(attr)
        define_method attr do
          @attributes[attr]
        end
        define_method "#{attr}=" do |value|
          @attributes[attr] = value
        end
      end
    end

    def simple_json_attributes
      @simple_json_attributes ||= []
    end

  end

end
end

{'fraction_non_alphanumeric': 0.08436724565756824, 'fraction_numerical': 0.0, 'mean_word_length': 2.7058823529411766, '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': '5817261', 'n_tokens_mistral': 613, 'n_tokens_neox': 598, 'n_words': 141}