Class: OrderQuery::SQL::Column
- Inherits:
-
Object
- Object
- OrderQuery::SQL::Column
- Defined in:
- lib/order_query/sql/column.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #column_name ⇒ Object
-
#initialize(column, scope) ⇒ Column
constructor
A new instance of Column.
- #quote(value) ⇒ Object
Constructor Details
#initialize(column, scope) ⇒ Column
Returns a new instance of Column.
6 7 8 9 |
# File 'lib/order_query/sql/column.rb', line 6 def initialize(column, scope) @column = column @scope = scope end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
4 5 6 |
# File 'lib/order_query/sql/column.rb', line 4 def column @column end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/order_query/sql/column.rb', line 4 def scope @scope end |
Instance Method Details
#column_name ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/order_query/sql/column.rb', line 11 def column_name @column_name ||= begin sql = column.[:sql] if sql sql.respond_to?(:call) ? sql.call : sql else connection.quote_table_name(scope.table_name) + '.' + connection.quote_column_name(column.name) end end end |
#quote(value) ⇒ Object
22 23 24 |
# File 'lib/order_query/sql/column.rb', line 22 def quote(value) connection.quote value end |