class AWS::SimpleWorkflow::TypeCollection

The base class for {WorkflowTypeCollection} and {ActivityTypeCollection}. @private

Attributes

domain[R]

@return [Domain]

Public Class Methods

new(domain, options = {}) click to toggle source

@param [Domain] The domain the (workflow or activity types belong to.

# File lib/aws/simple_workflow/type_collection.rb, line 25
def initialize domain, options = {}

  @domain = domain

  @named = options[:named]

  @registration_status = options[:registration_status] ? 
    options[:registration_status].to_s.upcase : 'REGISTERED'

  @reverse_order = options.key?(:reverse_order) ?
    !!options[:reverse_order] : false

  super

end

Public Instance Methods

[](name, version) click to toggle source

Returns the type with the given name and version.

# get a workflow type
domain.workflow_types['name','version']
domain.workflow_types.at('name','version')

# get an activity type
domain.activity_types['name','version']
domain.activity_types.at('name','version')

@param [String] Name of the type.

@param [String] Version of the type.

@return [ActivityType,WorkflowType]

# File lib/aws/simple_workflow/type_collection.rb, line 60
def [] name, version
  member_class.new(domain, name, version)
end
Also aliased as: at
at(name, version) click to toggle source
Alias for: []
create() click to toggle source
Alias for: register
deprecated() click to toggle source

@return [TypeCollection] Returns a collection that

will only enumerate deprecated types.
# File lib/aws/simple_workflow/type_collection.rb, line 72
def deprecated
  collection_with(:registration_status => 'DEPRECATED')
end
named(name) click to toggle source

@return [TypeCollection] Returns a collection that

enumerates types with the given name.  Each instance
will have a different version.
# File lib/aws/simple_workflow/type_collection.rb, line 86
def named name
  collection_with(:named => name.to_s)
end
register() click to toggle source
# File lib/aws/simple_workflow/type_collection.rb, line 65
def register
  raise NotImplementedError # implemented in subclasses
end
Also aliased as: create
reverse_order() click to toggle source

@return [TypeCollection] Returns a collection that

enumerates types in reverse alphabetical order.  Default
ordering is alphabetical.
# File lib/aws/simple_workflow/type_collection.rb, line 79
def reverse_order
  collection_with(:reverse_order => true)
end

Protected Instance Methods

_each_item(next_token, limit, options = {}) { |type| ... } click to toggle source
# File lib/aws/simple_workflow/type_collection.rb, line 107
def _each_item next_token, limit, options = {}, &block

  options[:domain] = domain.name
  options[:next_page_token] = next_token if next_token
  options[:maximum_page_size] = limit if limit
  options[:registration_status] ||= @registration_status
  options[:name] ||= @named if @named # may be nil
  options[:reverse_order] = @reverse_order unless 
    options.has_key?(:reverse_order)


  ruby_name = Core::Inflection.ruby_name(member_class.name)
  type_key = member_class.type_key
  client_method = :"list_#{ruby_name}s"

  response = client.send(client_method, options)
  response.data['typeInfos'].each do |desc|

    type = member_class.new_from(client_method, desc, domain, 
      desc[type_key]['name'], 
      desc[type_key]['version']) 

    yield(type)
    
  end

  response.data['nextPageToken']

end
collection_with(options = {}) click to toggle source
# File lib/aws/simple_workflow/type_collection.rb, line 91
def collection_with options = {}
  self.class.new(domain, {
    :registration_status => @registration_status,
    :reverse_order => @reverse_order,
    :named => @named,
    :config => config,
  }.merge(options))
end
member_class() click to toggle source
# File lib/aws/simple_workflow/type_collection.rb, line 101
def member_class
  name = self.class.name.split(%r::/).last.sub(%rCollection/, '')
  SimpleWorkflow.const_get(name)
end