<commit_before>module DataMapper

  # A database session
  class Session
    include Adamantium::Flat, Equalizer.new(:registry)

    # Return tracker
    #
    # @return [Hash<Object, State>]
    #   a mapping of identity objects to their current state
    #
    # @api private
    attr_reader :tracker

    # Return registry
    #
    # @return [Registry]
    #
    # @api private
    attr_reader :registry

    # Return model specific reader
    #
    # The container can use the passed block to load objects guarded by identity map.
    #
    # @example
    #   people = session.read(Person, :lastname => 'Doe')
    #
    # @param [Class] model
    #   the domain model class to be queried
    #
    # @return [Reader]
    #   a reader for instances of +model+
    #
    # @api public
    def reader(model)
      mapper = registry.resolve_model(model)
      Reader.new(self, mapper)
    end

    # Delete a domain object from the database and forget it
    #
    # @example
    #   person = session.first(Person)
    #   session.delete(person) # deletes person via person mapper
    #
    # @param [Object] object
    #   the domain object to be deleted
    #
    # @return [self]
    #
    # @api public
    def delete(object)
      state = state(object)
      old = old(state)
      old.delete
      tracker.delete(old.identity)

      self
    end

    # Returns whether a domain object is tracked in this session
    #
    # @example
    #   person = Person.new
    #   session.include?(person) # => false
    #   session.persist(person)
    #   session.include?(person) # => true
    #
    # @param [Object] object
    #   the domain object to be examined
    #
    # @return [true]<commit_msg>Use test verb to describe predicates<commit_after>module DataMapper

  # A database session
  class Session
    include Adamantium::Flat, Equalizer.new(:registry)

    # Return tracker
    #
    # @return [Hash<Object, State>]
    #   a mapping of identity objects to their current state
    #
    # @api private
    attr_reader :tracker

    # Return registry
    #
    # @return [Registry]
    #
    # @api private
    attr_reader :registry

    # Return model specific reader
    #
    # The container can use the passed block to load objects guarded by identity map.
    #
    # @example
    #   people = session.read(Person, :lastname => 'Doe')
    #
    # @param [Class] model
    #   the domain model class to be queried
    #
    # @return [Reader]
    #   a reader for instances of +model+
    #
    # @api public
    def reader(model)
      mapper = registry.resolve_model(model)
      Reader.new(self, mapper)
    end

    # Delete a domain object from the database and forget it
    #
    # @example
    #   person = session.first(Person)
    #   session.delete(person) # deletes person via person mapper
    #
    # @param [Object] object
    #   the domain object to be deleted
    #
    # @return [self]
    #
    # @api public
    def delete(object)
      state = state(object)
      old = old(state)
      old.delete
      tracker.delete(old.identity)

      self
    end

    # Test whether a domain object is tracked in this session
    #
    # @example
    #   person = Person.new
    #   session.include?(person) # => false
    #   session.persist(person)
    #   session.include?(person) # => true
    #
    # @param [Object] object
    #   the domain object to be examined
    #
    # @return [true]
{'fraction_non_alphanumeric': 0.09287383177570094, 'fraction_numerical': 0.0, 'mean_word_length': 2.1949626865671643, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2853595', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1017, 'n_words': 318}