Class: SimpleQuery::WhereClause
- Inherits:
-
Object
- Object
- SimpleQuery::WhereClause
- Defined in:
- lib/simple_query/clauses/where_clause.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
Instance Method Summary collapse
- #add(condition) ⇒ Object
-
#initialize(table) ⇒ WhereClause
constructor
A new instance of WhereClause.
- #to_arel ⇒ Object
Constructor Details
#initialize(table) ⇒ WhereClause
Returns a new instance of WhereClause.
7 8 9 10 |
# File 'lib/simple_query/clauses/where_clause.rb', line 7 def initialize(table) @table = table @conditions = [] end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/simple_query/clauses/where_clause.rb', line 5 def conditions @conditions end |
Instance Method Details
#add(condition) ⇒ Object
12 13 14 15 |
# File 'lib/simple_query/clauses/where_clause.rb', line 12 def add(condition) parsed_conditions = parse_condition(condition) @conditions.concat(parsed_conditions) end |
#to_arel ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/simple_query/clauses/where_clause.rb', line 17 def to_arel return nil if @conditions.empty? @conditions.inject do |combined, current| combined.and(current) end end |