Class: Literal
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Expr
#*, #+, #<, #<=, #>, #>=, #and, #asc, #desc, #eq, #in, #minus, #ne, #not, #plus
Constructor Details
#initialize(value) ⇒ Literal
342
343
344
|
# File 'lib/lilit_sql.rb', line 342
def initialize(value)
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
340
341
342
|
# File 'lib/lilit_sql.rb', line 340
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Object
362
363
364
|
# File 'lib/lilit_sql.rb', line 362
def ==(other)
other.class == self.class && other.state == state
end
|
#decl_sql ⇒ Object
350
351
352
353
354
355
356
357
358
359
360
|
# File 'lib/lilit_sql.rb', line 350
def decl_sql
if @value.nil?
'null'
elsif @value.is_a?(Integer) || @value.is_a?(Float)
@value.to_s
elsif @value.is_a?(String)
"'#{@value}'"
else
raise NotImplementedError, "Literal doesn't support render #{@value.class} (#{@value})"
end
end
|
#ref_sql ⇒ Object
346
347
348
|
# File 'lib/lilit_sql.rb', line 346
def ref_sql
decl_sql
end
|
#state ⇒ Object
366
367
368
|
# File 'lib/lilit_sql.rb', line 366
def state
instance_variables.map { |variable| instance_variable_get variable }
end
|