You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::SimpleWorkflow::HistoryEvent::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/simple_workflow/history_event.rb

Overview

A collection off attributes that provides method and hash style access to a collection of attributes.

If you are exploring a history event, you can call #keys to get a complete list of attribute names present. You can also reference the service API documentation that lists all history event types along with their returned attributes.

Indifferent Access

Here are a few examples showing the different ways to access an attribute:

event = workflow_executions.events.first

# equivalent
event.attributes.task_list
event.attributes[:task_list]
event.attributes['task_list']
event.attributes['taskList']

As shown in the example above keys and method names can be snake_cased or camelCased (strings or symbols).

Special Attributes

The following list of attributes are treated specially. Generally this means they return

  • timeout attributes (e.g. taskStartToCloseTimeout) are returned as integers (number of seconds) or the special symbol :none, implying there is no timeout.

  • childPolicy is cast to a symbol

  • activityType is returned as a ActivityType object.

  • workflowType is returned as a WorkflowType object.

  • workflowExecution is returned as a WorkflowExecution object.

  • taskList is returned as a string, not a hash.

  • taskPriority is returned as an Integer, not a String.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



205
206
207
# File 'lib/aws/simple_workflow/history_event.rb', line 205

def method_missing method
  self[method]
end

Instance Method Details

#[](key) ⇒ Object

Returns the attribute with the given name (key).

Parameters:

  • key (String, Symbol)

Returns:

  • Returns the attribute with the given name (key).



179
180
181
182
183
184
185
186
187
# File 'lib/aws/simple_workflow/history_event.rb', line 179

def [] key
  key = _camel_case(key)
  if @data.key?(key)
    _cast(key, @data[key])
  else
    msg = "no such attribute `#{key}`, valid keys are #{_key_string}"
    raise ArgumentError, msg
  end
end

#key?(key) ⇒ Boolean Also known as: member?, include?, has_key?

Returns true if the attribute with the given name is set.

Returns:

  • (Boolean)

    Returns true if the attribute with the given name is set.



197
198
199
# File 'lib/aws/simple_workflow/history_event.rb', line 197

def key? key
  @data.key?(_camel_case(key))
end

#keysArray<Symbol>

Returns a list of valid keys for this set of attributes.

Returns:

  • (Array<Symbol>)

    Returns a list of valid keys for this set of attributes.



191
192
193
# File 'lib/aws/simple_workflow/history_event.rb', line 191

def keys
  @data.keys.collect{|key| _snake_case(key) }
end

#to_hHash

Returns all of the attributes in a hash with snaked_cased and symbolized keys.

Returns:

  • (Hash)

    Returns all of the attributes in a hash with snaked_cased and symbolized keys.



211
212
213
214
215
216
217
218
219
220
# File 'lib/aws/simple_workflow/history_event.rb', line 211

def to_h
  @data.inject({}) do |h,(key,value)|
    value = _cast(key,value)
    if value.is_a?(Array)
      value = value.map{|v| v.is_a?(Attributes) ? v.to_h : v }
    end
    h[_snake_case(key)] = value.is_a?(Attributes) ? value.to_h : value
    h
  end
end