<commit_before>module Rohbau

  class Entity
    class << self; attr_accessor :__attributes__ end
    def self.attributes(*attributes)
      @__attributes__ ||= []
      @__attributes__ += attributes


      predicate_attributes = attributes.select do |attr|
        attr =~ /\?$/
      end

      regular_attributes = attributes - predicate_attributes

      predicate_attributes.each do |attribute|
        attribute_without_predicate = attribute.to_s.gsub(/\?$/, '')
        attr_accessor attribute_without_predicate

        define_method attribute do ||
          !!instance_variable_get(:"@#{attribute_without_predicate}")
        end
      end

      attr_accessor(*regular_attributes)
    end

    def ==(other)
      other && __attributes__.all? do |attr|
        self.public_send(attr) == other.public_send(attr)
      end
    end

    protected
    def __attributes__
      self.class.__attributes__ || []
    end
  end

end<commit_msg>Add respond_to to equality check of entity<commit_after>module Rohbau

  class Entity
    class << self; attr_accessor :__attributes__ end
    def self.attributes(*attributes)
      @__attributes__ ||= []
      @__attributes__ += attributes


      predicate_attributes = attributes.select do |attr|
        attr =~ /\?$/
      end

      regular_attributes = attributes - predicate_attributes

      predicate_attributes.each do |attribute|
        attribute_without_predicate = attribute.to_s.gsub(/\?$/, '')
        attr_accessor attribute_without_predicate

        define_method attribute do ||
          !!instance_variable_get(:"@#{attribute_without_predicate}")
        end
      end

      attr_accessor(*regular_attributes)
    end

    def ==(other)
      other && __attributes__.all? do |attr|
        other.respond_to?(attr) &&
          self.public_send(attr) == other.public_send(attr)
      end
    end

    protected
    def __attributes__
      self.class.__attributes__ || []
    end
  end

end
{'fraction_non_alphanumeric': 0.09387755102040816, 'fraction_numerical': 0.0, 'mean_word_length': 2.6722846441947565, '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': '6396883', 'n_tokens_mistral': 562, 'n_tokens_neox': 544, 'n_words': 116}