Class: SmqlToAR::ConditionTypes::EqualJoin

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

Constant Summary collapse

Operator =
'='
Expected =
[Hash]

Constants inherited from Condition

Condition::Where

Instance Attribute Summary

Attributes inherited from Condition

#cols, #value

Instance Method Summary collapse

Methods inherited from Condition

try_parse, #verify, #verify_allowed

Constructor Details

#initialize(*pars) ⇒ EqualJoin

Returns a new instance of EqualJoin.



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

def initialize *pars
	super( *pars)
	cols = {}
	@cols.each do |col|
		col_model = SmqlToAR.model_of col.last_model, col.col
		#p col_model: col_model.to_s, value: @value
		cols[col] = [col_model] + ConditionTypes.try_parse( col_model, @value)
	end
	@cols = cols
end

Instance Method Details

#build(builder, table) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/smql_to_ar/condition_types.rb', line 212

def build builder, table
	@cols.each do |col, sub|
		t = table + col.path + [col.col]
		#p sub: sub
		p col: col, joins: col.joins
		col.joins.each {|j, m| builder.join table+j, m }
		builder.join t, SmqlToAR.model_of( col.last_model, col.col)
		sub[1..-1].each {|one| one.build builder, t }
	end
	self
end

#verify_column(col) ⇒ Object



206
207
208
209
210
# File 'lib/smql_to_ar/condition_types.rb', line 206

def verify_column col
	refl = SmqlToAR.model_of col.last_model, col.col
	#p refl: refl, model: @model.name, col: col, :reflections => @model.reflections.keys
	raise NonExistingRelationError.new( %w[Relation], col)  unless refl
end