Sha256: 7c547e51a29454b1f3cb6522b234aa7f79bd4827e49bbf0c50add29467cae041

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

require "azure/tables"

module Azure
  module Tables

    class TablesCollection < Array

      # Public: Create an Azure::Tables::TablesCollection instance.
      #
      # query - A Hash with the query options passed to the server to get the tables.
      #
      # Returns the instance.
      def initialize(query = {}, service = Azure::Tables)
        @query = query
        @service = service
      end

      # Public: Creates an Azure::Tables::TablesCollection from entries feed.
      #
      # entries - An array of xml entries.
      # query   - A Hash with the query options passed to the server to get the tables.
      #
      # Returns an instance of Azure::Tables::EntitiesCollection.
      def self.from_entries(entries, query = {}, service = Azure::Tables)
        collection = self.new(query, service)

        entries.each do |entry|
          collection << Table.from_entry(entry)
        end

        collection
      end

      # Public: Set continuation tokens for this collection
      def continuation_token(next_table_name)
        @next_table_name = next_table_name
      end

      # Public: Indicates if the collection is a paginated result.
      # http://msdn.microsoft.com/en-us/library/windowsazure/dd135718
      #
      # Returs boolean.
      def paginated?
        @next_table_name ? true : false
      end

      # Public: Returns continuation results if exists.
      #
      # Returns an instance of Azure::Tables::TablesCollection
      def next
        return nil if !paginated?

        query = @query.merge({
          "NextTableName" => @next_table_name
        })

        @service.all(query)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 lib/azure/tables/tables_collection.rb
azure-0.1.0 lib/azure/tables/tables_collection.rb