Module: AWS::Flow::OptionsMethods

Included in:
ActivityOptions, WorkflowOptions
Defined in:
lib/aws/decider/options.rb

Overview

This module refactors out some of the common methods for the Options classes. Any class including this module should implement make_runtime_key method and default_keys method. default_keys method provides an array of keys that are considered to be the default options for that class. make_runtime_key method converts a passed in default key to it’s corresponding runtime key.

Instance Method Summary collapse

Instance Method Details

#get_default_optionsHash

Retrieves the default options.

Returns:

  • (Hash)

    A hash containing the default option names and their current values.



59
60
61
62
# File 'lib/aws/decider/options.rb', line 59

def get_default_options
  # Get the default options
  get_options(default_keys)
end

#get_full_optionsHash

Retrieves full options. It merges the runtime options with the remaining options

Returns:

  • (Hash)

    A hash containing the full option names and their current values.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/aws/decider/options.rb', line 70

def get_full_options
  # Initialize an empty hash
  options_hash = {}

  # Get all the properties held by this class
  options_keys = self.class.held_properties

  # Remove the unnecessary options (i.e. options not recognized by swf but
  # only by flow) from the options_keys array.
  default_keys.concat([:from_class]).each { |x| options_keys.delete(x) }

  # If the value for an option is held by the class, get it and store it
  # in a hash
  options_keys.each do |option|
    options_hash[option] = self.send(option) if self.send(option)
  end
  # Merge the options_hash with the runtime options
  options_hash.merge(self.get_runtime_options)
end

#get_runtime_optionsHash

Retrieves the runtime values for the default options

Returns:

  • (Hash)

    The runtime option names and their current values.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/aws/decider/options.rb', line 41

def get_runtime_options
  runtime_options = {}
  # For the default values that are present, convert the default keys into
  # runtime keys. i.e. remove 'default_' and 'default_task_' from the key
  # name and merge their values with the default values
  get_default_options.each do |key, val|
    new_key = make_runtime_key(key)
    new_val = get_options([new_key])
    runtime_options[new_key] = new_val.empty? ? val : new_val.values.first
  end
  runtime_options
end