<commit_before>module Virtus

  # Extensions common for both classes and instances
  module Extensions
    WRITER_METHOD_REGEXP   = /=\z/.freeze
    INVALID_WRITER_METHODS = %w[ == != === []= attributes= ].to_set.freeze
    RESERVED_NAMES         = [:attributes].to_set.freeze

    # A hook called when an object is extended with Virtus
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    def self.extended(object)
      super
      object.instance_eval do
        extend Methods
        extend InstanceMethods
        extend InstanceMethods::Constructor
        extend InstanceMethods::MassAssignment
      end
    end
    private_class_method :extended

    module Methods

      # @api private
      def self.extended(descendant)
        AttributeSet.create(descendant)
        descendant.instance_eval do
          extend attribute_set
        end
      end
      private_class_method :extended

      # Defines an attribute on an object's class
      #
      # @example
      #    class Book
      #      include Virtus
      #
      #      attribute :title,        String
      #      attribute :author,       String
      #      attribute :published_at, DateTime
      #      attribute :page_count,   Integer
      #      attribute :index                   # defaults to Object
      #    end
      #
      # @param [Symbol] name
      #   the name of an attribute
      #
      # @param [Class] type
      #   the type class of an attribute
      #
      # @param [#to_hash] options
      #   the extra options hash
      #
      # @return [self]
      #
      # @see Attribute.build
      #
      # @api public
      def attribute(name, type = nil, options = {})
        assert_valid_name(name)
        attribute_set << Attribute.build(type, merge_options(name, options))
        self
      end

      # @api public
      def values(&block)
        private :attributes= if instance_methods.include?(:attributes=)
        yield
        include(::Equalizer.new(*attribute_set.map(&:name)))
        self
      end

      # The list of writer methods that can be mass-assigned to in #attributes=
      #
      # @return [Set]
      #
      # @api private
      def allowed_writer_methods
        @allowed_writer_methods ||=
          begin
            allowed_writer_methods  = allowed_methods.grep(WRITER_METHOD_REGEXP).to_set<commit_msg>Remove explicit return in Extensions#values<commit_after>module Virtus

  # Extensions common for both classes and instances
  module Extensions
    WRITER_METHOD_REGEXP   = /=\z/.freeze
    INVALID_WRITER_METHODS = %w[ == != === []= attributes= ].to_set.freeze
    RESERVED_NAMES         = [:attributes].to_set.freeze

    # A hook called when an object is extended with Virtus
    #
    # @param [Object] object
    #
    # @return [undefined]
    #
    # @api private
    def self.extended(object)
      super
      object.instance_eval do
        extend Methods
        extend InstanceMethods
        extend InstanceMethods::Constructor
        extend InstanceMethods::MassAssignment
      end
    end
    private_class_method :extended

    module Methods

      # @api private
      def self.extended(descendant)
        AttributeSet.create(descendant)
        descendant.instance_eval do
          extend attribute_set
        end
      end
      private_class_method :extended

      # Defines an attribute on an object's class
      #
      # @example
      #    class Book
      #      include Virtus
      #
      #      attribute :title,        String
      #      attribute :author,       String
      #      attribute :published_at, DateTime
      #      attribute :page_count,   Integer
      #      attribute :index                   # defaults to Object
      #    end
      #
      # @param [Symbol] name
      #   the name of an attribute
      #
      # @param [Class] type
      #   the type class of an attribute
      #
      # @param [#to_hash] options
      #   the extra options hash
      #
      # @return [self]
      #
      # @see Attribute.build
      #
      # @api public
      def attribute(name, type = nil, options = {})
        assert_valid_name(name)
        attribute_set << Attribute.build(type, merge_options(name, options))
        self
      end

      # @see Virtus.default_value
      #
      # @api public
      def values(&block)
        private :attributes= if instance_methods.include?(:attributes=)
        yield
        include(::Equalizer.new(*attribute_set.map(&:name)))
      end

      # The list of writer methods that can be mass-assigned to in #attributes=
      #
      # @return [Set]
      #
      # @api private
      def allowed_writer_methods
        @allowed_writer_methods ||=
          begin
            allowed_writer_methods  = allowed_methods.grep(WRITER_METHOD_REGEXP).to_set
{'fraction_non_alphanumeric': 0.07838676318510858, 'fraction_numerical': 0.0, 'mean_word_length': 1.9079975947083583, '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': '4500686', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1318, 'n_words': 352}