Class: Dynamodb::Relation
- Inherits:
-
Object
- Object
- Dynamodb::Relation
- Defined in:
- lib/dynamodb/relation.rb
Constant Summary collapse
- OPERATOR_MAP =
{ eq: "=", gt: ">", gte: ">=", lt: "<", lte: "<=", begins_with: "begins_with", between: "BETWEEN" }.freeze
- QUERY_METHODS =
[ :index_name, :consistent_read, :scan_index_forward, :key_condition_expression, :filter_expression, :expression_attribute_names, :expression_attribute_values, :projection_expression, :exclusive_start_key ].freeze
- QUERY_INSTANCE_VARS =
[ :limit ].freeze
Instance Attribute Summary collapse
-
#attribute_expressors ⇒ Object
readonly
Returns the value of attribute attribute_expressors.
-
#consistent_read ⇒ Object
Returns the value of attribute consistent_read.
-
#expression_attribute_names ⇒ Object
readonly
Returns the value of attribute expression_attribute_names.
-
#expression_attribute_values ⇒ Object
readonly
Returns the value of attribute expression_attribute_values.
-
#filter_expression ⇒ Object
readonly
Returns the value of attribute filter_expression.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#key_condition_expression ⇒ Object
readonly
Returns the value of attribute key_condition_expression.
-
#offset_key ⇒ Object
readonly
Returns the value of attribute offset_key.
-
#projection_expression ⇒ Object
readonly
Returns the value of attribute projection_expression.
-
#scan_index_forward ⇒ Object
Returns the value of attribute scan_index_forward.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #all ⇒ Object
- #exclusive_start_key ⇒ Object
-
#initialize(source) ⇒ Relation
constructor
A new instance of Relation.
- #limit(int) ⇒ Object
- #query(args = {}) ⇒ Object
- #select(*args) ⇒ Object
- #to_query ⇒ Object
- #where(args) ⇒ Object
Constructor Details
#initialize(source) ⇒ Relation
Returns a new instance of Relation.
35 36 37 38 39 40 |
# File 'lib/dynamodb/relation.rb', line 35 def initialize(source) @source = source @attribute_expressors = {} @consistent_read = false @scan_index_forward = true end |
Instance Attribute Details
#attribute_expressors ⇒ Object (readonly)
Returns the value of attribute attribute_expressors.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def attribute_expressors @attribute_expressors end |
#consistent_read ⇒ Object
Returns the value of attribute consistent_read.
9 10 11 |
# File 'lib/dynamodb/relation.rb', line 9 def consistent_read @consistent_read end |
#expression_attribute_names ⇒ Object (readonly)
Returns the value of attribute expression_attribute_names.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def expression_attribute_names @expression_attribute_names end |
#expression_attribute_values ⇒ Object (readonly)
Returns the value of attribute expression_attribute_values.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def expression_attribute_values @expression_attribute_values end |
#filter_expression ⇒ Object (readonly)
Returns the value of attribute filter_expression.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def filter_expression @filter_expression end |
#index_name ⇒ Object
Returns the value of attribute index_name.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def index_name @index_name end |
#key_condition_expression ⇒ Object (readonly)
Returns the value of attribute key_condition_expression.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def key_condition_expression @key_condition_expression end |
#offset_key ⇒ Object
Returns the value of attribute offset_key.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def offset_key @offset_key end |
#projection_expression ⇒ Object (readonly)
Returns the value of attribute projection_expression.
10 11 12 |
# File 'lib/dynamodb/relation.rb', line 10 def projection_expression @projection_expression end |
#scan_index_forward ⇒ Object
Returns the value of attribute scan_index_forward.
9 10 11 |
# File 'lib/dynamodb/relation.rb', line 9 def scan_index_forward @scan_index_forward end |
#source ⇒ Object
Returns the value of attribute source.
9 10 11 |
# File 'lib/dynamodb/relation.rb', line 9 def source @source end |
Instance Method Details
#all ⇒ Object
63 64 65 |
# File 'lib/dynamodb/relation.rb', line 63 def all source._query(build_query) end |
#exclusive_start_key ⇒ Object
89 90 91 |
# File 'lib/dynamodb/relation.rb', line 89 def exclusive_start_key @offset_key end |
#limit(int) ⇒ Object
51 52 53 54 55 |
# File 'lib/dynamodb/relation.rb', line 51 def limit(int) @_limit = int build_expressions self end |
#query(args = {}) ⇒ Object
71 72 73 |
# File 'lib/dynamodb/relation.rb', line 71 def query(args = {}) source._query(args) end |
#select(*args) ⇒ Object
57 58 59 60 61 |
# File 'lib/dynamodb/relation.rb', line 57 def select(*args) @projection_expression = args.flatten build_expressions self end |
#to_query ⇒ Object
67 68 69 |
# File 'lib/dynamodb/relation.rb', line 67 def to_query build_query end |
#where(args) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/dynamodb/relation.rb', line 42 def where(args) args.each do |k, v| setter = "#{k}=".to_sym self.has_method?(setter) ? self.send(setter, v) : add_attribute_query(k,v) end build_expressions self end |