lib/azure/table/batch.rb in azure-0.7.0 vs lib/azure/table/batch.rb in azure-0.7.1
- old
+ new
@@ -20,11 +20,11 @@
require 'azure/core/http/http_error'
module Azure
module Table
# Represents a batch of table operations.
- #
+ #
# Example usage (block syntax):
#
# results = Batch.new "table", "partition" do
# insert "row1", {"meta"=>"data"}
# insert "row2", {"meta"=>"data"}
@@ -35,14 +35,14 @@
# results = Batch.new("table", "partition")
# .insert("row1", {"meta"=>"data"})
# .insert("row2", {"meta"=>"data"})
# .execute
#
- # which is equivalent to (as class):
- #
- # svc = TableSerice.new
+ # which is equivalent to (as class):
#
+ # svc = TableSerice.new
+ #
# batch = Batch.new "table", "partition"
# batch.insert "row1", {"meta"=>"data"}
# batch.insert "row2", {"meta"=>"data"}
#
# results = svc.execute_batch batch
@@ -82,14 +82,14 @@
class ResponseWrapper
def initialize(hash)
@hash = hash
end
- def uri
+ def uri
@hash[:uri]
end
-
+
def status_code
@hash[:status_code].to_i
end
def body
@@ -98,13 +98,13 @@
end
protected
def add_operation(method, uri, body=nil, headers=nil)
op = {
- :method => method,
- :uri => uri,
- :body => body,
+ :method => method,
+ :uri => uri,
+ :body => body,
:headers => headers
}
operations.push op
end
@@ -144,11 +144,11 @@
new_responses.push entity
when :put, :merge
# etag from headers
new_responses.push response[:headers]["etag"]
when :delete
- # true
+ # true
new_responses.push nil
end
end
}
@@ -176,19 +176,19 @@
if op[:headers]
op[:headers].each { |k,v|
body.add_line "#{k}: #{v}"
}
end
-
+
if op[:body]
body.add_line "Content-Type: application/atom+xml;type=entry"
body.add_line "Content-Length: #{op[:body].bytesize.to_s}"
body.add_line ""
body.add_line op[:body]
else
body.add_line ""
- end
+ end
content_id += 1
}
body.add_line "--#{changeset_id}--"
body.add_line "--#{batch_id}--"
@@ -197,40 +197,40 @@
# Public: Inserts new entity to the table.
#
# ==== Attributes
#
# * +row_key+ - String. The row key
- # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
+ # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
#
# See http://msdn.microsoft.com/en-us/library/azure/dd179433
public
def insert(row_key, entity_values)
check_entity_key(row_key)
- body = Azure::Table::Serialization.hash_to_entry_xml({
- "PartitionKey" => partition,
+ body = Azure::Table::Serialization.hash_to_entry_xml({
+ "PartitionKey" => partition,
"RowKey" => row_key
}.merge(entity_values) ).to_xml
add_operation(:post, @table_service.entities_uri(table), body)
self
end
- # Public: Updates an existing entity in a table. The Update Entity operation replaces
+ # Public: Updates an existing entity in a table. The Update Entity operation replaces
# the entire entity and can be used to remove properties.
#
# ==== Attributes
#
# * +row_key+ - String. The row key
- # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
- # * +options+ - Hash. Optional parameters.
+ # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
+ # * +options+ - Hash. Optional parameters.
#
# ==== Options
#
# Accepted key/value pairs in options parameter are:
# * :if_match - String. A matching condition which is required for update (optional, Default="*")
- # * :create_if_not_exists - Boolean. If true, and partition_key and row_key do not reference and existing entity,
+ # * :create_if_not_exists - Boolean. If true, and partition_key and row_key do not reference and existing entity,
# that entity will be inserted. If false, the operation will fail. (optional, Default=false)
#
# See http://msdn.microsoft.com/en-us/library/azure/dd179427
public
def update(row_key, entity_values, options={})
@@ -244,27 +244,27 @@
body = Azure::Table::Serialization.hash_to_entry_xml(entity_values).to_xml
add_operation(:put, uri, body, headers)
self
end
-
+
# Public: Updates an existing entity by updating the entity's properties. This operation
# does not replace the existing entity, as the update_entity operation does.
#
# ==== Attributes
#
# * +row_key+ - String. The row key
- # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
- # * +options+ - Hash. Optional parameters.
+ # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
+ # * +options+ - Hash. Optional parameters.
#
# ==== Options
#
# Accepted key/value pairs in options parameter are:
# * +if_match+ - String. A matching condition which is required for update (optional, Default="*")
- # * +create_if_not_exists+ - Boolean. If true, and partition_key and row_key do not reference and existing entity,
+ # * +create_if_not_exists+ - Boolean. If true, and partition_key and row_key do not reference and existing entity,
# that entity will be inserted. If false, the operation will fail. (optional, Default=false)
- #
+ #
# See http://msdn.microsoft.com/en-us/library/azure/dd179392
public
def merge(row_key, entity_values, options={})
check_entity_key(row_key)
@@ -283,11 +283,11 @@
#
# ==== Attributes
#
# * +row_key+ - String. The row key
# * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
- #
+ #
# See http://msdn.microsoft.com/en-us/library/azure/hh452241
public
def insert_or_merge(row_key, entity_values)
merge(row_key, entity_values, { :create_if_not_exists => true })
self
@@ -296,12 +296,12 @@
# Public: Inserts or updates a new entity into a table.
#
# ==== Attributes
#
# * +row_key+ - String. The row key
- # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
- #
+ # * +entity_values+ - Hash. A hash of the name/value pairs for the entity.
+ #
# See http://msdn.microsoft.com/en-us/library/azure/hh452242
public
def insert_or_replace(row_key, entity_values)
update(row_key, entity_values, { :create_if_not_exists => true })
self
@@ -310,10 +310,10 @@
# Public: Deletes an existing entity in the table.
#
# ==== Attributes
#
# * +row_key+ - String. The row key
- # * +options+ - Hash. Optional parameters.
+ # * +options+ - Hash. Optional parameters.
#
# ==== Options
#
# Accepted key/value pairs in options parameter are:
# * +if_match+ - String. A matching condition which is required for update (optional, Default="*")
\ No newline at end of file