Class: Cassava::WhereClause
- Inherits:
-
Struct
- Object
- Struct
- Cassava::WhereClause
- Defined in:
- lib/cassava/client.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#parts ⇒ Object
Returns the value of attribute parts.
Instance Method Summary collapse
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments
195 196 197 |
# File 'lib/cassava/client.rb', line 195 def arguments @arguments end |
#parts ⇒ Object
Returns the value of attribute parts
195 196 197 |
# File 'lib/cassava/client.rb', line 195 def parts @parts end |
Instance Method Details
#to_s ⇒ Object
211 212 213 |
# File 'lib/cassava/client.rb', line 211 def to_s "WHERE #{parts.join(' AND ')}" end |
#where(*args) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/cassava/client.rb', line 196 def where(*args) new_parts = self.parts.dup || [] new_arguments = self.arguments.dup || [] case args[0] when String new_parts << args[0] new_arguments += args[1..-1] when Hash new_parts += args[0].map { |key, value| "#{key} #{where_string(value)}" } new_arguments += args[0].values.flatten end self.class.new(new_parts, new_arguments) end |