<commit_before>require 'active_data/model/extensions'
require 'active_data/model/collectionizable'
require 'active_data/model/attributable'
require 'active_data/model/localizable'
require 'active_data/model/associations'
require 'active_data/model/nested_attributes'
require 'active_data/model/parameterizable'

require 'active_data/attributes/base'
require 'active_data/attributes/localized'

module ActiveData
  module Model
    class NotFound < ::StandardError
    end

    extend ActiveSupport::Concern

    included do
      include ActiveModel::Conversion
      include ActiveModel::Validations
      include ActiveModel::MassAssignmentSecurity
      include ActiveModel::Serialization
      include ActiveModel::Serializers::JSON
      include ActiveModel::Serializers::Xml

      include Attributable
      include Localizable
      include Collectionizable
      include Associations
      include NestedAttributes
      include Parameterizable
      extend ActiveModel::Naming
      extend ActiveModel::Translation

      self.include_root_in_json = false

      def initialize attributes = {}
        @attributes = self.class.initialize_attributes
        @new_record = true
        assign_attributes attributes
      end

      def self.i18n_scope
        :active_data
      end
    end

    module ClassMethods
      def instantiate data
        return data if data.instance_of? self

        data = data.stringify_keys
        instance = allocate

        attributes = initialize_attributes
        attributes.merge!(data.slice(*attributes.keys))

        data.slice(*association_names).each do |association, data|
          instance.send(:"#{association}=", data)
        end

        instance.instance_variable_set(:@attributes, attributes)
        instance.instance_variable_set(:@new_record, false)

        instance
      end
    end

    def errors
      @errors ||= ActiveModel::Errors.new(self)
    end

    def persisted?
      !@new_record
    end

    def inspect
      "#<#{self.class} #{attributes.map { |name, value| "#{name}: #{value.inspect}" }.join(' ')}>"
    end

    def == other<commit_msg>Proper instantiate model check<commit_after>require 'active_data/model/extensions'
require 'active_data/model/collectionizable'
require 'active_data/model/attributable'
require 'active_data/model/localizable'
require 'active_data/model/associations'
require 'active_data/model/nested_attributes'
require 'active_data/model/parameterizable'

require 'active_data/attributes/base'
require 'active_data/attributes/localized'

module ActiveData
  module Model
    class NotFound < ::StandardError
    end

    extend ActiveSupport::Concern

    included do
      include ActiveModel::Conversion
      include ActiveModel::Validations
      include ActiveModel::MassAssignmentSecurity
      include ActiveModel::Serialization
      include ActiveModel::Serializers::JSON
      include ActiveModel::Serializers::Xml

      include Attributable
      include Localizable
      include Collectionizable
      include Associations
      include NestedAttributes
      include Parameterizable
      extend ActiveModel::Naming
      extend ActiveModel::Translation

      self.include_root_in_json = false

      def initialize attributes = {}
        @attributes = self.class.initialize_attributes
        @new_record = true
        assign_attributes attributes
      end

      def self.i18n_scope
        :active_data
      end
    end

    module ClassMethods
      def instantiate data
        return data if data.class.include? ActiveData::Model

        data = data.stringify_keys
        instance = allocate

        attributes = initialize_attributes
        attributes.merge!(data.slice(*attributes.keys))

        data.slice(*association_names).each do |association, data|
          instance.send(:"#{association}=", data)
        end

        instance.instance_variable_set(:@attributes, attributes)
        instance.instance_variable_set(:@new_record, false)

        instance
      end
    end

    def errors
      @errors ||= ActiveModel::Errors.new(self)
    end

    def persisted?
      !@new_record
    end

    def inspect
      "#<#{self.class} #{attributes.map { |name, value| "#{name}: #{value.inspect}" }.join(' ')}>"
    end

    def == other
{'fraction_non_alphanumeric': 0.08010275572162541, 'fraction_numerical': 0.0009341429238673517, 'mean_word_length': 3.1143131604226704, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2939093', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1098, 'n_words': 256}