Class: IseshimaStore::WhereClause
- Inherits:
-
Object
- Object
- IseshimaStore::WhereClause
- Defined in:
- lib/iseshima_store/where_clause.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
Instance Method Summary collapse
- #+(condition) ⇒ Object
-
#initialize ⇒ WhereClause
constructor
A new instance of WhereClause.
Constructor Details
#initialize ⇒ WhereClause
Returns a new instance of WhereClause.
5 6 7 |
# File 'lib/iseshima_store/where_clause.rb', line 5 def initialize @conditions = [] end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
3 4 5 |
# File 'lib/iseshima_store/where_clause.rb', line 3 def conditions @conditions end |
Instance Method Details
#+(condition) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/iseshima_store/where_clause.rb', line 9 def +(condition) # conditions like where(name: 'taro', email: '[email protected]') if condition.is_a?(Hash) condition.each do |key, value| @conditions << [key.to_s, '=', value] end # condisions like where('age', '>=', 16) elsif condition.is_a?(Array) && condition.length == 3 @conditions << condition # Other else raise ArgumentError.new("wrong format of arguments") end self end |