Module: Sequel::SQL::NoBooleanInputMethods

Included in:
NumericExpression, StringExpression
Defined in:
lib/sequel/sql.rb

Overview

This module augments the default initalize method for the ComplexExpression subclass it is included in, so that attempting to use boolean input when initializing a NumericExpression or StringExpression results in an error.

Instance Method Summary collapse

Instance Method Details

#initialize(op, *args) ⇒ Object

Raise an Error if one of the args would be boolean in an SQL context, otherwise call super.



273
274
275
276
277
278
279
280
281
# File 'lib/sequel/sql.rb', line 273

def initialize(op, *args)
  args.each do |a|
    case a
    when BooleanExpression, TrueClass, FalseClass, NilClass, Hash, Array
      raise(Error, "cannot apply #{op} to a boolean expression")
    end
  end
  super
end