Sha256: b0837a8a034f5e0ad7b42528f8f61d83d9d7d786de8c020be22bc4496562ef1a

Contents?: true

Size: 946 Bytes

Versions: 5

Compression:

Stored size: 946 Bytes

Contents

module Scram::DSL
  # Default definitions from builders
  module Definitions
    # Adds a custom comparator using a builder
    # @param builder [Scram::Builders::ComparatorBuilder] Builder to merge into the usable comparators
    def self.add_comparators(builder)
      COMPARATORS.merge!(builder.comparators)
    end

    # Default comparators.
    # @note These names are used within the DB as key names for conditions. Pay attention when adding them,
    #   and plan not to be changing them.
    # TODO: Inclusive inequalities
    COMPARATORS = Builders::ComparatorBuilder.new do
      comparator :equals do |a, b|
        a == b
      end

      comparator :greater_than do |a, b|
        a > b
      end

      comparator :less_than do |a, b|
        a < b
      end

      comparator :includes do |a, b|
        a.send(:include?, b)
      end

      comparator :not_equals do |a, b|
        a != b
      end
    end.comparators
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scram-0.1.4 lib/scram/dsl/definitions.rb
scram-0.1.3 lib/scram/dsl/definitions.rb
scram-0.1.2 lib/scram/dsl/definitions.rb
scram-0.1.1 lib/scram/dsl/definitions.rb
scram-0.1.0 lib/scram/dsl/definitions.rb