<commit_before>module Opium
  module Model
    module Queryable
      extend ActiveSupport::Concern

      module ClassMethods
        delegate :count, :total_count, to: :criteria

        def all( constraints = nil )
          constraints ? imbued_where( arrayize( constraints ), '$all' ) : criteria
        end

        alias_method :all_in, :all

        def between( constraints )
          start = constraints.map {|key, range| [key, range.begin]}
          inclusive = constraints.reject {|_, range| range.exclude_end?}.map {|key, range| [key, range.end]}
          exclusive = constraints.select {|_, range| range.exclude_end?}.map {|key, range| [key, range.end]}
          gte( start ).lte( inclusive ).lt( exclusive )
        end

        def exists( constraints )
          imbued_where( constraints.map {|key, value| [key, value.to_bool] }, '$exists' )
        end

        def gt( constraints )
          imbued_where( constraints, '$gt' )
        end

        def gte( constraints )
          imbued_where( constraints, '$gte' )
        end

        def lt( constraints )
          imbued_where( constraints, '$lt' )
        end

        def lte( constraints )
          imbued_where( constraints, '$lte' )
        end<commit_msg>Apparently, ruby versions prior to 2.2 did not freeze the TrueClass and FalseClass singletons. For the moment, enforcing this in the code for Queryable#exists<commit_after>module Opium
  module Model
    module Queryable
      extend ActiveSupport::Concern

      module ClassMethods
        delegate :count, :total_count, to: :criteria

        def all( constraints = nil )
          constraints ? imbued_where( arrayize( constraints ), '$all' ) : criteria
        end

        alias_method :all_in, :all

        def between( constraints )
          start = constraints.map {|key, range| [key, range.begin]}
          inclusive = constraints.reject {|_, range| range.exclude_end?}.map {|key, range| [key, range.end]}
          exclusive = constraints.select {|_, range| range.exclude_end?}.map {|key, range| [key, range.end]}
          gte( start ).lte( inclusive ).lt( exclusive )
        end

        def exists( constraints )
          imbued_where( constraints.map {|key, value| [key, value.to_bool.freeze] }, '$exists' )
        end

        def gt( constraints )
          imbued_where( constraints, '$gt' )
        end

        def gte( constraints )
          imbued_where( constraints, '$gte' )
        end

        def lt( constraints )
          imbued_where( constraints, '$lt' )
        end

        def lte( constraints )
          imbued_where( constraints, '$lte' )
        end
{'fraction_non_alphanumeric': 0.10538286580742987, 'fraction_numerical': 0.000758150113722517, 'mean_word_length': 2.2540073982737363, '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': '1334512', 'n_tokens_mistral': 764, 'n_tokens_neox': 729, 'n_words': 222}