Class: F

Inherits:
Object
  • Object
show all
Defined in:
lib/dolzenko/django_f_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr_name) ⇒ F

Returns a new instance of F.



39
40
41
# File 'lib/dolzenko/django_f_object.rb', line 39

def initialize(attr_name)
  self.attr_name = attr_name.to_s
end

Instance Attribute Details

#attr_nameObject

Returns the value of attribute attr_name.



34
35
36
# File 'lib/dolzenko/django_f_object.rb', line 34

def attr_name
  @attr_name
end

#klassObject

Returns the value of attribute klass.



35
36
37
# File 'lib/dolzenko/django_f_object.rb', line 35

def klass
  @klass
end

#operandObject

Returns the value of attribute operand.



37
38
39
# File 'lib/dolzenko/django_f_object.rb', line 37

def operand
  @operand
end

#operatorObject

Returns the value of attribute operator.



36
37
38
# File 'lib/dolzenko/django_f_object.rb', line 36

def operator
  @operator
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/dolzenko/django_f_object.rb', line 53

def empty?
  false
end

#to_sql(formatter = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/dolzenko/django_f_object.rb', line 43

def to_sql(formatter = nil)
  self.klass ||= formatter.environment.relation.klass
  sql = klass.my_quote_columns(attr_name)
  if operator && operand
    operand.klass = klass if operand.is_a?(F)
    sql << " #{ operator } #{ operand.is_a?(F) ? operand.to_sql(formatter) : klass.connection.quote(operand) }"
  end
  sql
end