Class: Commutator::Options::Query
- Inherits:
-
Object
- Object
- Commutator::Options::Query
- Includes:
- Util::Fluent
- Defined in:
- lib/commutator/options/query.rb
Instance Method Summary collapse
- #asc ⇒ Object
- #desc ⇒ Object
-
#initialize ⇒ Query
constructor
A new instance of Query.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/commutator/options/query.rb', line 27 def initialize @expression_attribute_values ||= Expressions::AttributeValues.new @expression_attribute_names ||= Expressions::AttributeNames.new @key_condition_expression ||= Expressions::ConditionExpression.new( attribute_names: @expression_attribute_names, attribute_values: @expression_attribute_values) @filter_expression ||= Expressions::ConditionExpression.new( attribute_names: @expression_attribute_names, attribute_values: @expression_attribute_values) @projection_expression ||= Expressions::ProjectionExpression.new( attribute_names: @expression_attribute_names) end |
Instance Method Details
#asc ⇒ Object
43 44 45 |
# File 'lib/commutator/options/query.rb', line 43 def asc scan_index_forward(true) end |
#desc ⇒ Object
47 48 49 |
# File 'lib/commutator/options/query.rb', line 47 def desc scan_index_forward(false) end |
#to_h ⇒ Object Also known as: to_hash
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/commutator/options/query.rb', line 51 def to_h hash = { table_name: table_name, limit: limit, consistent_read: consistent_read, index_name: index_name, select: select, exclusive_start_key: exclusive_start_key, scan_index_forward: scan_index_forward, return_consumed_capacity: return_consumed_capacity, projection_expression: projection_expression.to_s, expression_attribute_names: expression_attribute_names.to_h, expression_attribute_values: expression_attribute_values.to_h, key_condition_expression: key_condition_expression.to_s(wrap: false), filter_expression: filter_expression.to_s(wrap: false) } hash.keep_if { |_key, value| value.present? || value == false } end |