Class: WhereClause
- Defined in:
- lib/activeleopard/query_clauses/where_clause.rb
Instance Method Summary collapse
- #append(options) ⇒ Object (also: #<<)
- #as_sql ⇒ Object
-
#initialize(options = []) ⇒ WhereClause
constructor
A new instance of WhereClause.
- #values ⇒ Object
Constructor Details
#initialize(options = []) ⇒ WhereClause
Returns a new instance of WhereClause.
4 5 6 7 8 9 10 |
# File 'lib/activeleopard/query_clauses/where_clause.rb', line 4 def initialize( = []) unless .is_a?(Array) && .length <= 2 raise InvalidInput, "Where takes 1 or 2 arguments" end @conditions = parse_conditions() end |
Instance Method Details
#append(options) ⇒ Object Also known as: <<
21 22 23 |
# File 'lib/activeleopard/query_clauses/where_clause.rb', line 21 def append() conditions.merge!(parse_conditions()) end |
#as_sql ⇒ Object
16 17 18 19 |
# File 'lib/activeleopard/query_clauses/where_clause.rb', line 16 def as_sql return "" if conditions.empty? " WHERE " + conditions_as_sql end |
#values ⇒ Object
12 13 14 |
# File 'lib/activeleopard/query_clauses/where_clause.rb', line 12 def values conditions.values.flatten end |