class AWS::SimpleWorkflow::HistoryEvent

## Getting History Events

History events belong to workflow executions. You can get them from an execution two ways:

## History Event Attributes

All history events respond to the following 4 methods:

For a complete list of event types and a complete list of attributes returned with each event type, see the service API documentation.

Because the service returns attributes with camelCase name the structure returned by {#attributes} allows you to access attributes by their snake_case name or their camelCase name:

event.attributes.workflow_type
event.attributes['workflowType']

See {HistoryEvent::Attributes} for more information about working with the returned attributes.

Attributes

attributes[R]

@return [Attributes] Returns an object that provides hash-like

access to the history event attributes.
created_at[R]

@return [Time] When the event history was created.

event_id[R]

@return [Integer] Returns the event id.

event_type[R]

@return [String] Returns the name of the history event type.

id[R]

@return [Integer] Returns the event id.

workflow_execution[R]

@return [WorkflowExecution] The workflow execution this history

event belongs to.

Public Class Methods

new(workflow_execution, details) click to toggle source

@param [WorkflowExecution] workflow_execution

@param [Hash,String] details A hash or JSON string describing

the history event.
Calls superclass method AWS::Core::Model::new
# File lib/aws/simple_workflow/history_event.rb, line 68
def initialize workflow_execution, details

  @workflow_execution = workflow_execution
  @details = details.is_a?(String) ? JSON.parse(details) : details
  @event_type = @details['eventType']
  @event_id = @details['eventId']
  @created_at = Time.at(@details['eventTimestamp'])

  attributes_key = "#{event_type}EventAttributes"
  attributes_key[0] = attributes_key[0,1].downcase
  attribute_data = @details[attributes_key] || {}
  @attributes = Attributes.new(workflow_execution, attribute_data)

  super

end

Public Instance Methods

inspect() click to toggle source

@api private

# File lib/aws/simple_workflow/history_event.rb, line 120
def inspect
  "<#{self.class.name} #{to_h.inspect}>"
end
to_h() click to toggle source

@return [Hash] Returns a hash representation of the event.

# File lib/aws/simple_workflow/history_event.rb, line 104
def to_h
  {
    :event_type => event_type,
    :event_id => event_id,
    :created_at => created_at,
    :attributes => attributes.to_h,
  }
end
to_json() click to toggle source

@return [String] Returns a JSON representation of this workflow

execution.
# File lib/aws/simple_workflow/history_event.rb, line 115
def to_json
  @details.to_json
end