Class: Dorm::WhereDSL
- Inherits:
-
Object
- Object
- Dorm::WhereDSL
- Defined in:
- lib/dorm/query_builder.rb
Overview
DSL for building WHERE conditions
Defined Under Namespace
Classes: Condition, FieldCondition
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #add_param(value) ⇒ Object
-
#initialize(table_name, param_counter) ⇒ WhereDSL
constructor
A new instance of WhereDSL.
- #method_missing(field_name, *args) ⇒ Object
Constructor Details
#initialize(table_name, param_counter) ⇒ WhereDSL
Returns a new instance of WhereDSL.
346 347 348 349 350 |
# File 'lib/dorm/query_builder.rb', line 346 def initialize(table_name, param_counter) @table_name = table_name @param_counter = param_counter @params = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(field_name, *args) ⇒ Object
352 353 354 |
# File 'lib/dorm/query_builder.rb', line 352 def method_missing(field_name, *args) FieldCondition.new(field_name, @table_name, self) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
344 345 346 |
# File 'lib/dorm/query_builder.rb', line 344 def params @params end |
Instance Method Details
#add_param(value) ⇒ Object
356 357 358 359 360 |
# File 'lib/dorm/query_builder.rb', line 356 def add_param(value) @params << value @param_counter += 1 "$#{@param_counter}" end |