<commit_before>require 'httparty'
require 'multi_json'
require 'active_model'

module ApiEntity
  class NotFound < StandardError; end
  class Error < StandardError; end

  extend ActiveSupport::Concern

  included do
    include ActiveModel::Validations
    include ActiveModel::Conversion
    extend  ActiveModel::Naming

    include HTTParty
    include MultiJson
    base_uri Rails.application.config.api_host
    # debug_output

    attr_reader :attributes

    attr_accessor :casted_by

    class_eval do
      def resource_path
        "/#{self.class.name.underscore.pluralize}/#{to_param}"
      end

      def to_param
        id
      end
    end
  end

  def initialize(attributes = {})
    class_name = self.class.name.downcase

    attributes = HashWithIndifferentAccess.new(attributes)

    if attributes.present? && attributes.has_key?(class_name)<commit_msg>[rails 5.1.3] using ActiveSupport::HashWithIndifferentAccess<commit_after>require 'httparty'
require 'multi_json'
require 'active_model'

module ApiEntity
  class NotFound < StandardError; end
  class Error < StandardError; end

  extend ActiveSupport::Concern

  included do
    include ActiveModel::Validations
    include ActiveModel::Conversion
    extend  ActiveModel::Naming

    include HTTParty
    include MultiJson
    base_uri Rails.application.config.api_host
    # debug_output

    attr_reader :attributes

    attr_accessor :casted_by

    class_eval do
      def resource_path
        "/#{self.class.name.underscore.pluralize}/#{to_param}"
      end

      def to_param
        id
      end
    end
  end

  def initialize(attributes = {})
    class_name = self.class.name.downcase

    attributes = ActiveSupport::HashWithIndifferentAccess.new(attributes)

    if attributes.present? && attributes.has_key?(class_name)
{'fraction_non_alphanumeric': 0.07300884955752213, 'fraction_numerical': 0.00165929203539823, 'mean_word_length': 3.455665024630542, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6297573', 'n_tokens_mistral': 540, 'n_tokens_neox': 519, 'n_words': 118}