<commit_before>module Vault
  module Properties
    def key(key=nil)
      return @_key if key.nil?
      @_key = property(key, true).name
    end

    def property(name, primary=false, &block)
      Property.new(name, primary, &block).tap do |prop|
        properties << prop
        define_property_methods(prop.name)

        # FIXME: Ugh, ActiveModel fails with this, I can't do incremental method
        # definition, you have to define them all at once (so undefine/define
        # each time if you don't know all the properties upfront, like here.)
        undefine_attribute_methods
        define_attribute_methods(property_names)
      end
    end

    def properties
      @_properties ||= Set.new
    end

    def property_names
      properties.map(&:name)
    end

    def define_property_methods(name)
      class_eval <<-ruby, __FILE__, __LINE__
        def #{name}
          read_attribute(:#{name})
        end

        def #{name}=(value)
          write_attribute(:#{name}, value)
        end
      ruby
    end

    class Property
      attr_reader :name

      def initialize(name, primary=false, &default)
        @name = name.to_s
        @default = default || lambda {}
        @primary = primary
      end

      def primary?
        @primary
      end

      def default
        @default.call
      end

      # Set requires both #hash and #eql? to check for inclusion
      def hash # :nodoc:
        name.hash
      end
<commit_msg>Old stuff is old<commit_after>module Vault
  module Properties
    def key(key=nil)
      return @_key if key.nil?
      @_key = property(key).name
    end

    def property(name, &block)
      Property.new(name, &block).tap do |prop|
        properties << prop
        define_property_methods(prop.name)

        # FIXME: Ugh, ActiveModel fails with this, I can't do incremental method
        # definition, you have to define them all at once (so undefine/define
        # each time if you don't know all the properties upfront, like here.)
        undefine_attribute_methods
        define_attribute_methods(property_names)
      end
    end

    def properties
      @_properties ||= Set.new
    end

    def property_names
      properties.map(&:name)
    end

    def define_property_methods(name)
      class_eval <<-ruby, __FILE__, __LINE__
        def #{name}
          read_attribute(:#{name})
        end

        def #{name}=(value)
          write_attribute(:#{name}, value)
        end
      ruby
    end

    class Property
      attr_reader :name

      def initialize(name, &default)
        @name = name.to_s
        @default = default || lambda {}
      end

      def default
        @default.call
      end

      # Set requires both #hash and #eql? to check for inclusion
      def hash # :nodoc:
        name.hash
      end

{'fraction_non_alphanumeric': 0.08185053380782918, 'fraction_numerical': 0.0, 'mean_word_length': 2.0687772925764194, 'pattern_counts': {'":': 0, '<': 11, '<?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': '886082', 'n_tokens_mistral': 821, 'n_tokens_neox': 787, 'n_words': 251}