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