Class: AzureClient::Table
- Inherits:
-
Object
- Object
- AzureClient::Table
- Defined in:
- lib/azure_client/table.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #delete(retry_policy = @retry_policy) ⇒ Object
- #delete_entity(partition_key, row_key, retry_policy = @retry_policy) ⇒ Object
- #get_entity(partition_key, row_key, retry_policy = @retry_policy) ⇒ Object
-
#initialize(name, table_service, retry_policy) ⇒ Table
constructor
A new instance of Table.
- #query(query_hash, retry_policy = @retry_policy) ⇒ Object
- #store_entity(entity, retry_policy = @retry_policy) ⇒ Object
Constructor Details
#initialize(name, table_service, retry_policy) ⇒ Table
Returns a new instance of Table.
5 6 7 8 9 |
# File 'lib/azure_client/table.rb', line 5 def initialize(name, table_service, retry_policy) @name = name @table_service = table_service @retry_policy = retry_policy end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/azure_client/table.rb', line 3 def name @name end |
Instance Method Details
#delete(retry_policy = @retry_policy) ⇒ Object
26 27 28 29 30 |
# File 'lib/azure_client/table.rb', line 26 def delete(retry_policy = @retry_policy) retry_policy.retry { @table_service.delete_table(name) } end |
#delete_entity(partition_key, row_key, retry_policy = @retry_policy) ⇒ Object
32 33 34 35 36 |
# File 'lib/azure_client/table.rb', line 32 def delete_entity(partition_key, row_key, retry_policy = @retry_policy) retry_policy.retry { @table_service.delete_entity(name, partition_key, row_key) } end |
#get_entity(partition_key, row_key, retry_policy = @retry_policy) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/azure_client/table.rb', line 19 def get_entity(partition_key, row_key, retry_policy = @retry_policy) retry_policy.retry { entity_hash = @table_service.get_entity(name, partition_key, row_key).properties TableEntity.new(entity_hash["PartitionKey"], entity_hash["RowKey"], entity_hash["TimeStamp"], entity_hash.tap { |h| h.delete(:PartitionKey); h.delete(:RowKey)}) } end |
#query(query_hash, retry_policy = @retry_policy) ⇒ Object
38 39 40 41 42 |
# File 'lib/azure_client/table.rb', line 38 def query(query_hash, retry_policy = @retry_policy) retry_policy.retry { @table_service.query_entities(name, query_hash) } end |
#store_entity(entity, retry_policy = @retry_policy) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/azure_client/table.rb', line 11 def store_entity(entity, retry_policy = @retry_policy) retry_policy.retry { entity_hash = {"PartitionKey" => entity.partition_key, "RowKey" => entity.row_key}.merge(entity.content_hash) @table_service.insert_or_replace_entity(name, entity_hash) } end |