<commit_before># encoding: utf-8
module Origin

  # An origin selectable is selectable, in that it has the ability to select
  # document from the database. The selectable module brings all functionality
  # to the selectable that has to do with building MongoDB selectors.
  module Selectable
    extend Macroable

    LINE_STRING = "LineString"
    POINT = "Point"
    POLYGON = "Polygon"

    # @attribute [rw] negating If the next spression is negated.
    # @attribute [rw] selector The query selector.
    attr_accessor :negating, :selector

    # Add the $all criterion.
    #
    # @example Add the criterion.
    #   selectable.all(field: [ 1, 2 ])
    #
    # @example Execute an $all in a where query.
    #   selectable.where(:field.all => [ 1, 2 ])
    #
    # @param [ Hash ] criterion The key value pairs for $all matching.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def all(criterion = nil)
      send(strategy || :__union__, with_array_values(criterion), "$all")
    end
    alias :all_in :all
    key :all, :union, "$all"

    # Add the $and criterion.
    #
    # @example Add the criterion.
    #   selectable.and({ field: value }, { other: value })
    #
    # @param [ Array<Hash> ] criterion Multiple key/value pair matches that
    #   all must match to return results.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def and(*criterion)
      __multi__(criterion, "$and")
    end
    alias :all_of :and

    # Add the range selection.
    #
    # @example Match on results within a single range.
    #   selectable.between(field: 1..2)
    #
    # @example Match on results between multiple ranges.
    #   selectable.between(field: 1..2, other: 5..7)
    #
    # @param [ Hash ] criterion Multiple key/range pairs.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def between(criterion = nil)
      selection(criterion) do |selector, field, value|
        selector.store(
          field,
          { "$gte" => value.min, "$lte" => value.max }
        )
      end
    end

    # Select with an $elemMatch.
    #
    # @example Add criterion for a single match.
    #   selectable.elem_match(field: { name: "value" })
    #
    # @example Add criterion for multiple matches.
    #   selectable.elem_match(
    #     field: { name: "value" },
    #     other: { name: "value"}
    #   )
    #
    # @example Execute an $elemMatch in a where query.
    #   selectable.where(:field.elem_match => { name: "value" })
    #
    # @param [ Hash ] criterion The field/match pairs.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def elem_match(criterion = nil)
      __override__(criterion, "$elemMatch")
    end
    key :elem_match, :override, "$elemMatch"

    # Add the $exists selection.
    #
    # @example Add a single selection.
    #   selectable.exists(field: true)
    #
    # @example Add multiple selections.
    #   selectable.exists(field: true, other: false)
    #
    # @example Execute an $exists in a where query.
    #   selectable.where(:field.exists => true)
    #
    # @param [ Hash ] criterion The field/boolean existence checks.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def exists(criterion = nil)
      typed_override(criterion, "$exists") do |value|
        ::Boolean.evolve(value)
      end
    end
    key :exists, :override, "$exists" do |value|
      ::Boolean.evolve(value)
    end

    def geo_intersects(criterion = nil)
      __merge__(criterion)
    end
    key :line, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => LINE_STRING, "coordinates" => value }
    end
    key :point, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => POINT, "coordinates" => value }
    end
    key :polygon, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => POLYGON, "coordinates" => value }
    end

    # Add the $gt criterion to the selector.
    #
    # @example Add the $gt criterion.
    #   selectable.gt(age: 60)
    #
    # @example Execute an $gt in a where query.
    #   selectable.where(:field.gt => 10)
    #
    # @param [ Hash ] criterion The field/value pairs to check.
    #<commit_msg>Add geo_intersects rdoc.<commit_after># encoding: utf-8
module Origin

  # An origin selectable is selectable, in that it has the ability to select
  # document from the database. The selectable module brings all functionality
  # to the selectable that has to do with building MongoDB selectors.
  module Selectable
    extend Macroable

    LINE_STRING = "LineString"
    POINT = "Point"
    POLYGON = "Polygon"

    # @attribute [rw] negating If the next spression is negated.
    # @attribute [rw] selector The query selector.
    attr_accessor :negating, :selector

    # Add the $all criterion.
    #
    # @example Add the criterion.
    #   selectable.all(field: [ 1, 2 ])
    #
    # @example Execute an $all in a where query.
    #   selectable.where(:field.all => [ 1, 2 ])
    #
    # @param [ Hash ] criterion The key value pairs for $all matching.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def all(criterion = nil)
      send(strategy || :__union__, with_array_values(criterion), "$all")
    end
    alias :all_in :all
    key :all, :union, "$all"

    # Add the $and criterion.
    #
    # @example Add the criterion.
    #   selectable.and({ field: value }, { other: value })
    #
    # @param [ Array<Hash> ] criterion Multiple key/value pair matches that
    #   all must match to return results.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def and(*criterion)
      __multi__(criterion, "$and")
    end
    alias :all_of :and

    # Add the range selection.
    #
    # @example Match on results within a single range.
    #   selectable.between(field: 1..2)
    #
    # @example Match on results between multiple ranges.
    #   selectable.between(field: 1..2, other: 5..7)
    #
    # @param [ Hash ] criterion Multiple key/range pairs.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def between(criterion = nil)
      selection(criterion) do |selector, field, value|
        selector.store(
          field,
          { "$gte" => value.min, "$lte" => value.max }
        )
      end
    end

    # Select with an $elemMatch.
    #
    # @example Add criterion for a single match.
    #   selectable.elem_match(field: { name: "value" })
    #
    # @example Add criterion for multiple matches.
    #   selectable.elem_match(
    #     field: { name: "value" },
    #     other: { name: "value"}
    #   )
    #
    # @example Execute an $elemMatch in a where query.
    #   selectable.where(:field.elem_match => { name: "value" })
    #
    # @param [ Hash ] criterion The field/match pairs.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def elem_match(criterion = nil)
      __override__(criterion, "$elemMatch")
    end
    key :elem_match, :override, "$elemMatch"

    # Add the $exists selection.
    #
    # @example Add a single selection.
    #   selectable.exists(field: true)
    #
    # @example Add multiple selections.
    #   selectable.exists(field: true, other: false)
    #
    # @example Execute an $exists in a where query.
    #   selectable.where(:field.exists => true)
    #
    # @param [ Hash ] criterion The field/boolean existence checks.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 1.0.0
    def exists(criterion = nil)
      typed_override(criterion, "$exists") do |value|
        ::Boolean.evolve(value)
      end
    end
    key :exists, :override, "$exists" do |value|
      ::Boolean.evolve(value)
    end

    # Add a $geoIntersects selection. Symbol operators must be used as shown in
    # the examples to expand the criteria.
    #
    # @note The only valid geometry shapes for a $geoIntersects are: :line,
    #   :point, and :polygon.
    #
    # @example Add a geo intersect criterion for a line.
    #   query.geo_intersects(:location.line => [[ 1, 10 ], [ 2, 10 ]])
    #
    # @example Add a geo intersect criterion for a point.
    #   query.geo_intersects(:location.point => [[ 1, 10 ]])
    #
    # @example Add a geo intersect criterion for a polygon.
    #   query.geo_intersects(:location.point => [[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]])
    #
    # @param [ Hash ] criterion The criterion.
    #
    # @return [ Selectable ] The cloned selectable.
    #
    # @since 2.0.0
    def geo_intersects(criterion = nil)
      __merge__(criterion)
    end
    key :line, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => LINE_STRING, "coordinates" => value }
    end
    key :point, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => POINT, "coordinates" => value }
    end
    key :polygon, :override, "$geoIntersects", "$geometry" do |value|
      { "type" => POLYGON, "coordinates" => value }
    end

    # Add the $gt criterion to the selector.
    #
    # @example Add the $gt criterion.
    #   selectable.gt(age: 60)
    #
    # @example Execute an $gt in a where query.
    #   selectable.where(:field.gt => 10)
    #
    # @param [ Hash ] criterion The field/value pairs to check.
    #
{'fraction_non_alphanumeric': 0.12085106382978723, 'fraction_numerical': 0.008617021276595745, 'mean_word_length': 2.3975424647632817, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '5361804', 'n_tokens_mistral': 3134, 'n_tokens_neox': 2947, 'n_words': 912}