Class: AWS::Flow::YAMLDataConverter

Inherits:
Object
  • Object
show all
Defined in:
aws-flow-ruby/aws-flow/lib/aws/decider/data_converter.rb

Overview

Note:

There is a 32K (32,768) character limit on activity/workflow input and output. If the amount of data that you need to pass exceeds this limit, use S3DataConverter instead.

Serializes/deserializes Ruby objects using YAML format. This is the default data converter for the AWS Flow Framework for Ruby.

Instance Method Summary (collapse)

Instance Method Details

- (Object) dump(object)

Serializes a Ruby object into a YAML string.

Parameters:

  • object (Object)

    The object to serialize.

Returns:

  • the object's data in YAML format.



34
35
36
37
38
39
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/data_converter.rb', line 34

def dump(object)
  if object.is_a? Exception
    return YAML.dump_stream(object, object.backtrace)
  end
  object.to_yaml
end

- (Object) load(source)

Deserializes a YAML string into a Ruby object.

Parameters:

  • source (String)

    The YAML string to deserialize.

Returns:

  • a Ruby object generated from the YAML string.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/data_converter.rb', line 48

def load(source)
  return nil if source.nil?
  output = YAML.load source
  if output.is_a? Exception
    documents = YAML.load_stream(source)
    if YAML::ENGINE.yamler == 'syck'
      documents = documents.documents
    end
    backtrace = documents.find {|x| ! x.is_a? Exception}
    output.set_backtrace(backtrace.to_a)
  end
  output
end