Class: SmqlToAR::ConditionTypes::NotInRange

Inherits:
Condition
  • Object
show all
Defined in:
lib/smql_to_ar/condition_types.rb

Constant Summary collapse

Operator =
'!..'
Where =
'%s NOT BETWEEN %s AND %s'
Expected =
[Range, lambda {|val| Array === val && 2 == val.length } ]

Instance Attribute Summary

Attributes inherited from Condition

#cols, #value

Instance Method Summary collapse

Methods inherited from Condition

#condition_build, inspect, #inspect, try_parse, #verify, #verify_allowed, #verify_column

Methods included from Assertion

#raise_if, #raise_unless

Constructor Details

#initialize(model, cols, val) ⇒ NotInRange

Returns a new instance of NotInRange.



185
186
187
188
189
190
191
192
# File 'lib/smql_to_ar/condition_types.rb', line 185

def initialize model, cols, val
	if Array === val
		f, l = val
		f, l = Time.parse(f), Time.parse(l)  if f.kind_of? String
		val = f..l
	end
	super model, cols, val
end

Instance Method Details

#not_in_range_build(builder, table) ⇒ Object Also known as: build



194
195
196
197
198
199
200
201
# File 'lib/smql_to_ar/condition_types.rb', line 194

def not_in_range_build builder, table
	builder.wobs (v1 = builder.vid).to_sym => @value.begin, (v2 = builder.vid).to_sym => @value.end
	@cols.each do |col|
		col.joins builder, table
		builder.where self.class::Where % [ builder.column( table+col.path, col.col), v1, v2]
	end
	self
end