Class: Dorm::WhereDSL::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/dorm/query_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject (readonly)

Returns the value of attribute params.



412
413
414
# File 'lib/dorm/query_builder.rb', line 412

def params
  @params
end

#sqlObject (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_sqlObject



429
430
431
# File 'lib/dorm/query_builder.rb', line 429

def to_sql
  @sql
end