Class: OrderQuery::SQL::Column
- Inherits:
-
Object
- Object
- OrderQuery::SQL::Column
- Defined in:
- lib/order_query/sql/column.rb
Overview
A column in the given scope.
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(scope, column) ⇒ Column
constructor
A new instance of Column.
- #quote(value) ⇒ Object
Constructor Details
#initialize(scope, column) ⇒ Column
Returns a new instance of Column.
9 10 11 12 |
# File 'lib/order_query/sql/column.rb', line 9 def initialize(scope, column) @scope = scope @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
7 8 9 |
# File 'lib/order_query/sql/column.rb', line 7 def column @column end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
7 8 9 |
# File 'lib/order_query/sql/column.rb', line 7 def scope @scope end |
Instance Method Details
#column_name ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/order_query/sql/column.rb', line 14 def column_name @column_name ||= begin sql = column.custom_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
26 27 28 |
# File 'lib/order_query/sql/column.rb', line 26 def quote(value) connection.quote value end |