<commit_before>module Ephemeral

  module Base

    require 'active_support/core_ext/object/blank'
    require 'active_support/core_ext/string/inflections'

    def self.included(base)
      base.extend ClassMethods
      base.send(:attr_accessor, :relations)
      base.send(:attr_writer, :collections)
    end

    def collections
      @collections ||= {}
    end

    module ClassMethods

      def collects(name=nil, args={})
        return @@collections unless name
        class_name = args[:class_name] || name.to_s.classify
        @@collections ||= {}
        @@collections[name] = Ephemeral::Collection.new(class_name)

        self.send :define_method, name do
          self.collections[class_name] ||= Ephemeral::Collection.new(class_name)
          self.collections[class_name]#.objects
        end

        self.send :define_method, "#{name}=" do |objects|
          self.collections[class_name] = Ephemeral::Collection.new(class_name, objects)
        end

      end

      def has_one(name, args={})
        class_name = args[:class_name] || name.to_s.classify
        self.send :define_method, name do
          self.relations ||= {}
          self.relations[class_name] ||= Ephemeral::Relation.new(class_name).materialize
        end
        self.send :define_method, "#{name}=" do |object|
          self.relations ||= {}
          self.relations[class_name] = Ephemeral::Relation.new(class_name).materialize(object)
        end<commit_msg>Undo undo<commit_after>module Ephemeral

  module Base

    require 'active_support/core_ext/object/blank'
    require 'active_support/core_ext/string/inflections'

    def self.included(base)
      base.extend ClassMethods
      base.send(:attr_accessor, :relations)
      base.send(:attr_writer, :collections)
    end

    def collections
      @collections ||= {}
    end

    module ClassMethods

      def collects(name=nil, args={})
        return @@collections unless name
        class_name = args[:class_name] || name.to_s.classify
        @@collections ||= {}
        @@collections[name] = Ephemeral::Collection.new(class_name)

        self.send :define_method, name do
          self.collections[class_name] ||= [] #Ephemeral::Collection.new(class_name)
          self.collections[class_name]#.objects
        end

        self.send :define_method, "#{name}=" do |objects|
          self.collections[class_name] = Ephemeral::Collection.new(class_name, objects)
        end

      end

      def has_one(name, args={})
        class_name = args[:class_name] || name.to_s.classify
        self.send :define_method, name do
          self.relations ||= {}
          self.relations[class_name] ||= Ephemeral::Relation.new(class_name).materialize
        end
        self.send :define_method, "#{name}=" do |object|
          self.relations ||= {}
          self.relations[class_name] = Ephemeral::Relation.new(class_name).materialize(object)
        end
{'fraction_non_alphanumeric': 0.11943874058863792, 'fraction_numerical': 0.0, 'mean_word_length': 2.8109517601043024, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4081020', 'n_tokens_mistral': 925, 'n_tokens_neox': 869, 'n_words': 154}