Class: F

Inherits:
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.



42
43
44
# File 'lib/dolzenko/django_f_object.rb', line 42

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

Instance Attribute Details

#attr_nameObject

Returns the value of attribute attr_name.



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

def attr_name
  @attr_name
end

#klassObject

Returns the value of attribute klass.



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

def klass
  @klass
end

#operandObject

Returns the value of attribute operand.



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

def operand
  @operand
end

#operatorObject

Returns the value of attribute operator.



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

def operator
  @operator
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/dolzenko/django_f_object.rb', line 56

def empty?
  false
end

#to_sql(formatter = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/dolzenko/django_f_object.rb', line 46

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