Class: Dorm::WhereDSL::Condition
- Inherits:
-
Object
- Object
- Dorm::WhereDSL::Condition
- Defined in:
- lib/dorm/query_builder.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
Instance Method Summary collapse
- #and(other_condition) ⇒ Object
-
#initialize(sql, params) ⇒ Condition
constructor
A new instance of Condition.
- #or(other_condition) ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(sql, params) ⇒ Condition
Returns a new instance of Condition.
414 415 416 417 |
# File 'lib/dorm/query_builder.rb', line 414 def initialize(sql, params) @sql = sql @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
412 413 414 |
# File 'lib/dorm/query_builder.rb', line 412 def params @params end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
412 413 414 |
# File 'lib/dorm/query_builder.rb', line 412 def sql @sql end |
Instance Method Details
#and(other_condition) ⇒ Object
419 420 421 422 |
# File 'lib/dorm/query_builder.rb', line 419 def and(other_condition) combined_params = @params + other_condition.params Condition.new("(#{@sql}) AND (#{other_condition.sql})", combined_params) end |
#or(other_condition) ⇒ Object
424 425 426 427 |
# File 'lib/dorm/query_builder.rb', line 424 def or(other_condition) combined_params = @params + other_condition.params Condition.new("(#{@sql}) OR (#{other_condition.sql})", combined_params) end |
#to_sql ⇒ Object
429 430 431 |
# File 'lib/dorm/query_builder.rb', line 429 def to_sql @sql end |