Module: Sequel::SQL::NoBooleanInputMethods

Included in:
NumericExpression, StringExpression
Defined in:
lib/sequel_core/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.



235
236
237
238
239
240
241
242
243
# File 'lib/sequel_core/sql.rb', line 235

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