<commit_before>class Fabrication::Schematic::Definition

  GENERATORS = [
    Fabrication::Generator::ActiveRecord,
    Fabrication::Generator::DataMapper,
    Fabrication::Generator::Sequel,
    Fabrication::Generator::Mongoid,
    Fabrication::Generator::Base
  ]

  attr_accessor :klass
  def initialize(klass, &block)
    self.klass = klass
    instance_eval(&block) if block_given?
  end

  def after_build(&block)
    callbacks[:after_build] ||= []
    callbacks[:after_build] << block
  end

  def after_create(&block)
    callbacks[:after_create] ||= []
    callbacks[:after_create] << block
  end

  def attribute(name)
    attributes.select { |a| a.name == name }.first
  end

  def append_or_update_attribute(attribute_name, value, params={}, &block)
    attribute = Fabrication::Schematic::Attribute.new(attribute_name, value, params, &block)
    if index = attributes.index { |a| a.name == attribute.name }
      attribute.transient! if attributes[index].transient?
      attributes[index] = attribute
    else
      attributes << attribute
    end
  end

  attr_writer :attributes
  def attributes
    @attributes ||= []
  end

  attr_writer :callbacks
  def callbacks
    @callbacks ||= {}
  end

  def generator
    @generator ||= GENERATORS.detect { |gen| gen.supports?(klass) }<commit_msg>use Enumerabe#detect for getting the first element on condition<commit_after>class Fabrication::Schematic::Definition

  GENERATORS = [
    Fabrication::Generator::ActiveRecord,
    Fabrication::Generator::DataMapper,
    Fabrication::Generator::Sequel,
    Fabrication::Generator::Mongoid,
    Fabrication::Generator::Base
  ]

  attr_accessor :klass
  def initialize(klass, &block)
    self.klass = klass
    instance_eval(&block) if block_given?
  end

  def after_build(&block)
    callbacks[:after_build] ||= []
    callbacks[:after_build] << block
  end

  def after_create(&block)
    callbacks[:after_create] ||= []
    callbacks[:after_create] << block
  end

  def attribute(name)
    attributes.detect { |a| a.name == name }
  end

  def append_or_update_attribute(attribute_name, value, params={}, &block)
    attribute = Fabrication::Schematic::Attribute.new(attribute_name, value, params, &block)
    if index = attributes.index { |a| a.name == attribute.name }
      attribute.transient! if attributes[index].transient?
      attributes[index] = attribute
    else
      attributes << attribute
    end
  end

  attr_writer :attributes
  def attributes
    @attributes ||= []
  end

  attr_writer :callbacks
  def callbacks
    @callbacks ||= {}
  end

  def generator
    @generator ||= GENERATORS.detect { |gen| gen.supports?(klass) }
{'fraction_non_alphanumeric': 0.1181339352896915, 'fraction_numerical': 0.0, 'mean_word_length': 3.9794007490636703, 'pattern_counts': {'":': 0, '<': 15, '<?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': '397518', 'n_tokens_mistral': 829, 'n_tokens_neox': 820, 'n_words': 173}