<commit_before>module Dun
  class Activity
    attr_reader :data

    def self.inherited(subclass)
      return if Kernel.method_defined? subclass.name
      
      Kernel.class_eval %Q{
        def #{subclass.name}(data = {}, &p)
          #{subclass.name}.new(data).call(&p)
        end
      }

    rescue SyntaxError, TypeError
      
    end

    class << self

      def initializations
        @initializations ||= []
      end
      
      def <<(data = {})
        new(data).call
      end

      def data_reader *attrs
        
        attrs.each do |attr|
          define_method attr do
            instance_variable_get("@#{attr}") ||\
            instance_variable_set("@#{attr}", data[attr.to_sym] || data[attr.to_s])
          end
        end
        
      end

      def set attr, value
        define_method(attr) {value}
      end
      
    end
    
    def initialize(data)
      @data = data
    end
    
    def call
      'dun'
    end

    private

    def get_or_set(attr, &p)
      value = instance_variable_get("@#{attr}")
      return value if value
      value = p.call
      instance_variable_set("@#{attr}", value)
    end

    def default(attr, value)
      if send(attr).nil?
        instance_variable_set "@#{attr}", value
      end
    end

  end

end<commit_msg>clean code<commit_after>module Dun
  class Activity
    attr_reader :data

    def self.inherited subclass
      return if Kernel.method_defined? subclass.name
      
      Kernel.class_eval %Q{
        def #{subclass.name} data = {}, &p
          #{subclass.name}.new(data).call &p
        end
      }

    rescue SyntaxError, TypeError
      
    end

    class << self

      def << data = {}
        new(data).call
      end

      def data_reader *attrs
        
        attrs.each do |attr|
          define_method attr do
            instance_variable_get("@#{attr}") ||\
            instance_variable_set("@#{attr}", data[attr.to_sym] || data[attr.to_s])
          end
        end
        
      end

      def set attr, value
        define_method(attr) {value}
      end
      
    end
    
    def initialize data
      @data = data
    end
    
    def call
      'dun'
    end

    private

    def get_or_set attr, &p
      value = instance_variable_get "@#{attr}"
      return value if value
      value = p.call
      instance_variable_set "@#{attr}", value
    end

    def default attr, value
      instance_variable_set "@#{attr}", value if send(attr).nil?
    end

  end

end
{'fraction_non_alphanumeric': 0.09939879759519038, 'fraction_numerical': 0.0, 'mean_word_length': 1.6867599569429494, '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': '1584728', 'n_tokens_mistral': 773, 'n_tokens_neox': 763, 'n_words': 189}