Class: Azure::Storage::Table::Query
- Inherits:
-
Object
- Object
- Azure::Storage::Table::Query
- Defined in:
- table/lib/azure/storage/table/query.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#next_partition_key ⇒ Object
readonly
Returns the value of attribute next_partition_key.
-
#next_row_key ⇒ Object
readonly
Returns the value of attribute next_row_key.
-
#partition_key ⇒ Object
readonly
Returns the value of attribute partition_key.
-
#row_key ⇒ Object
readonly
Returns the value of attribute row_key.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#table_service ⇒ Object
readonly
Returns the value of attribute table_service.
-
#top_n ⇒ Object
readonly
Returns the value of attribute top_n.
Instance Method Summary collapse
- #_build_filter_string ⇒ Object
- #execute ⇒ Object
- #from(table_name) ⇒ Object
-
#initialize(table = "", partition = nil, row = nil, &block) ⇒ Query
constructor
A new instance of Query.
- #next_partition(next_partition_key) ⇒ Object
- #next_row(next_row_key) ⇒ Object
- #partition(partition_key) ⇒ Object
- #row(row_key) ⇒ Object
- #select(*p) ⇒ Object
- #top(n) ⇒ Object
- #where(*p) ⇒ Object
Constructor Details
#initialize(table = "", partition = nil, row = nil, &block) ⇒ Query
Returns a new instance of Query.
29 30 31 32 33 34 35 36 37 38 |
# File 'table/lib/azure/storage/table/query.rb', line 29 def initialize(table = "", partition = nil, row = nil, &block) @table = table @partition_key = partition @row_key = row @fields = [] @filters = [] @top_n = nil @table_service = Azure::Storage::Table::TableService.create_from_env self.instance_eval(&block) if block_given? end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
44 45 46 |
# File 'table/lib/azure/storage/table/query.rb', line 44 def fields @fields end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
45 46 47 |
# File 'table/lib/azure/storage/table/query.rb', line 45 def filters @filters end |
#next_partition_key ⇒ Object (readonly)
Returns the value of attribute next_partition_key.
48 49 50 |
# File 'table/lib/azure/storage/table/query.rb', line 48 def next_partition_key @next_partition_key end |
#next_row_key ⇒ Object (readonly)
Returns the value of attribute next_row_key.
49 50 51 |
# File 'table/lib/azure/storage/table/query.rb', line 49 def next_row_key @next_row_key end |
#partition_key ⇒ Object (readonly)
Returns the value of attribute partition_key.
41 42 43 |
# File 'table/lib/azure/storage/table/query.rb', line 41 def partition_key @partition_key end |
#row_key ⇒ Object (readonly)
Returns the value of attribute row_key.
42 43 44 |
# File 'table/lib/azure/storage/table/query.rb', line 42 def row_key @row_key end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
40 41 42 |
# File 'table/lib/azure/storage/table/query.rb', line 40 def table @table end |
#table_service ⇒ Object (readonly)
Returns the value of attribute table_service.
51 52 53 |
# File 'table/lib/azure/storage/table/query.rb', line 51 def table_service @table_service end |
#top_n ⇒ Object (readonly)
Returns the value of attribute top_n.
46 47 48 |
# File 'table/lib/azure/storage/table/query.rb', line 46 def top_n @top_n end |
Instance Method Details
#_build_filter_string ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'table/lib/azure/storage/table/query.rb', line 105 def _build_filter_string result = "" clauses = [] filters.each { |f| clauses.push "#{f[0]} #{f[1]} #{Azure::Storage::Table::EdmType.serialize_query_value(f[2])}" } return nil if clauses.length == 0 result << clauses.join(" and ") result end |
#execute ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'table/lib/azure/storage/table/query.rb', line 93 def execute @table_service.query_entities(@table, partition_key: @partition_key, row_key: @row_key, select: @fields.map { |f| f.to_s }, filter: _build_filter_string, top: (@top_n ? @top_n.to_i : @top_n), continuation_token: { next_partition_key: @next_partition_key, next_row_key: @next_row_key }) end |
#from(table_name) ⇒ Object
53 54 55 56 |
# File 'table/lib/azure/storage/table/query.rb', line 53 def from(table_name) @table = table_name self end |
#next_partition(next_partition_key) ⇒ Object
83 84 85 86 |
# File 'table/lib/azure/storage/table/query.rb', line 83 def next_partition(next_partition_key) @next_partition_key = next_partition_key self end |
#next_row(next_row_key) ⇒ Object
88 89 90 91 |
# File 'table/lib/azure/storage/table/query.rb', line 88 def next_row(next_row_key) @next_row_key = next_row_key self end |
#partition(partition_key) ⇒ Object
58 59 60 61 |
# File 'table/lib/azure/storage/table/query.rb', line 58 def partition(partition_key) @partition_key = partition_key self end |
#row(row_key) ⇒ Object
63 64 65 66 |
# File 'table/lib/azure/storage/table/query.rb', line 63 def row(row_key) @row_key = row_key self end |
#select(*p) ⇒ Object
68 69 70 71 |
# File 'table/lib/azure/storage/table/query.rb', line 68 def select(*p) @fields.concat(p) self end |
#top(n) ⇒ Object
78 79 80 81 |
# File 'table/lib/azure/storage/table/query.rb', line 78 def top(n) @top_n = n self end |
#where(*p) ⇒ Object
73 74 75 76 |
# File 'table/lib/azure/storage/table/query.rb', line 73 def where(*p) @filters.push(p) self end |