Class: Column
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Expr
#*, #+, #<, #<=, #>, #>=, #and, #asc, #desc, #eq, #in, #minus, #ne, #not, #plus
Constructor Details
#initialize(name, origin = nil, from = nil) ⇒ Column
Returns a new instance of Column.
264
265
266
267
268
|
# File 'lib/lilit_sql.rb', line 264
def initialize(name, origin = nil, from = nil)
@name = name
@origin = origin
@from = from
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
262
263
264
|
# File 'lib/lilit_sql.rb', line 262
def name
@name
end
|
#origin ⇒ Object
Returns the value of attribute origin.
262
263
264
|
# File 'lib/lilit_sql.rb', line 262
def origin
@origin
end
|
Instance Method Details
#==(other) ⇒ Object
292
293
294
|
# File 'lib/lilit_sql.rb', line 292
def ==(other)
other.class == self.class && other.state == state
end
|
#decl_sql ⇒ Object
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/lilit_sql.rb', line 278
def decl_sql
s = ''
if origin
origin_sql = if origin.is_a?(Proc)
origin.call.ref_sql
else
origin.ref_sql
end
s += "#{origin_sql} as " if origin_sql != @name.to_s
end
s += @name.to_s
s
end
|
#ref_sql ⇒ Object
274
275
276
|
# File 'lib/lilit_sql.rb', line 274
def ref_sql
"#{@from.alias_name}.#{@name}"
end
|
#state ⇒ Object
296
297
298
|
# File 'lib/lilit_sql.rb', line 296
def state
instance_variables.map { |variable| instance_variable_get variable }
end
|
#with_from(from) ⇒ Object
270
271
272
|
# File 'lib/lilit_sql.rb', line 270
def with_from(from)
Column.new(@name, @origin, from)
end
|