class Azure::Table::Query
Attributes
fields[R]
filters[R]
next_partition_key[R]
next_row_key[R]
partition_key[R]
row_key[R]
table[R]
table_service[R]
top_n[R]
Public Class Methods
new(table="", partition=nil, row=nil, &block)
click to toggle source
# File lib/azure/table/query.rb, line 21 def initialize(table="", partition=nil, row=nil, &block) @table = table @partition_key = partition @row_key = row @fields = [] @filters = [] @top_n = nil @table_service = Azure::Table::TableService.new self.instance_eval(&block) if block_given? end
Public Instance Methods
_build_filter_string()
click to toggle source
# File lib/azure/table/query.rb, line 99 def _build_filter_string result = "" clauses = [] filters.each { |f| clauses.push "#{f[0].to_s} #{f[1].to_s} #{Azure::Table::EdmType.serialize_query_value(f[2])}" } return nil if clauses.length == 0 result << clauses.join(" and ") result end
execute()
click to toggle source
# File lib/azure/table/query.rb, line 85 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)
click to toggle source
# File lib/azure/table/query.rb, line 45 def from(table_name) @table = table_name self end
next_partition(next_partition_key)
click to toggle source
# File lib/azure/table/query.rb, line 75 def next_partition(next_partition_key) @next_partition_key = next_partition_key self end
next_row(next_row_key)
click to toggle source
# File lib/azure/table/query.rb, line 80 def next_row(next_row_key) @next_row_key = next_row_key self end
partition(partition_key)
click to toggle source
# File lib/azure/table/query.rb, line 50 def partition(partition_key) @partition_key = partition_key self end
row(row_key)
click to toggle source
# File lib/azure/table/query.rb, line 55 def row(row_key) @row_key = row_key self end
select(*p)
click to toggle source
# File lib/azure/table/query.rb, line 60 def select(*p) @fields.concat(p) self end
top(n)
click to toggle source
# File lib/azure/table/query.rb, line 70 def top(n) @top_n = n self end
where(*p)
click to toggle source
# File lib/azure/table/query.rb, line 65 def where(*p) @filters.push(p) self end