Class: Dynamoid::Criteria::WhereConditions
- Inherits:
-
Object
- Object
- Dynamoid::Criteria::WhereConditions
- Defined in:
- lib/dynamoid/criteria/where_conditions.rb
Instance Attribute Summary collapse
-
#string_conditions ⇒ Object
readonly
Returns the value of attribute string_conditions.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ WhereConditions
constructor
A new instance of WhereConditions.
- #keys ⇒ Object
- #update_with_hash(hash) ⇒ Object
- #update_with_string(query, placeholders) ⇒ Object
Constructor Details
#initialize ⇒ WhereConditions
Returns a new instance of WhereConditions.
9 10 11 12 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 9 def initialize @hash_conditions = [] @string_conditions = [] end |
Instance Attribute Details
#string_conditions ⇒ Object (readonly)
Returns the value of attribute string_conditions.
7 8 9 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 7 def string_conditions @string_conditions end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 33 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 30 def [](key) hash = @hash_conditions.find { |h| h.key?(key) } hash[key] if hash end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 26 def empty? @hash_conditions.empty? && @string_conditions.empty? end |
#keys ⇒ Object
22 23 24 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 22 def keys @hash_conditions.flat_map(&:keys) end |
#update_with_hash(hash) ⇒ Object
14 15 16 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 14 def update_with_hash(hash) @hash_conditions << hash.symbolize_keys end |
#update_with_string(query, placeholders) ⇒ Object
18 19 20 |
# File 'lib/dynamoid/criteria/where_conditions.rb', line 18 def update_with_string(query, placeholders) @string_conditions << [query, placeholders] end |