Module: Scram::DSL::Definitions

Defined in:
lib/scram/dsl/definitions.rb

Overview

Default definitions from builders

Constant Summary collapse

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.

Default comparators. TODO: Inclusive inequalities

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

Class Method Summary collapse

Class Method Details

.add_comparators(builder) ⇒ Object

Adds a custom comparator using a builder

Parameters:

  • builder (Scram::Builders::ComparatorBuilder)

    Builder to merge into the usable comparators


6
7
8
# File 'lib/scram/dsl/definitions.rb', line 6

def self.add_comparators(builder)
  COMPARATORS.merge!(builder.comparators)
end