Class: F
- Inherits:
-
Object
- Object
- F
- Defined in:
- lib/dolzenko/django_f_object.rb
Instance Attribute Summary collapse
-
#attr_name ⇒ Object
Returns the value of attribute attr_name.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#operand ⇒ Object
Returns the value of attribute operand.
-
#operator ⇒ Object
Returns the value of attribute operator.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(attr_name) ⇒ F
constructor
A new instance of F.
- #to_sql(formatter = nil) ⇒ Object
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_name ⇒ Object
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 |
#klass ⇒ Object
Returns the value of attribute klass.
35 36 37 |
# File 'lib/dolzenko/django_f_object.rb', line 35 def klass @klass end |
#operand ⇒ Object
Returns the value of attribute operand.
37 38 39 |
# File 'lib/dolzenko/django_f_object.rb', line 37 def operand @operand end |
#operator ⇒ Object
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
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 |