class AWS::Flow::Options

The base class for all options classes in the AWS Flow Framework for Ruby.

Attributes

default_classes[RW]

The set of default options. These are used when ‘use_defaults` is set to `true` on {#initialize}.

Public Class Methods

inherited(child) click to toggle source

Sets the default classes on a child class (a class derived from {Options}).

# File lib/aws/decider/options.rb, line 40
def self.inherited(child)
  child.precursors ||= []
  default_classes = child.ancestors.map do |precursor|
    if precursor.methods.map(&:to_sym).include? :default_classes
      precursor.default_classes
    end
  end.compact.flatten
  child.instance_variable_set("@default_classes", default_classes)
end
new(hash={}, use_defaults = false) click to toggle source

Creates a new {Options} instance.

@param [Hash] hash

*Optional*. A hash of values to use as the default options for this
instance. The members of this hash are defined by classes derived from
{Options}.

@param [true, false] use_defaults

*Optional*. In derived classes, this parameter is used to tell the
constructor to use the set of default options as the runtime options.
This has no effect in the base {Options} class.
# File lib/aws/decider/options.rb, line 99
def initialize(hash={}, use_defaults = false)
  @precursors ||= []
  hash.each_pair do |key, val|
    if self.methods.map(&:to_sym).include? "#{key}=".to_sym
      self.send("#{key}=", val)
    end
  end
end

Public Instance Methods

get_options(options, extra_to_add = {}) click to toggle source

Merges specified options with the set of options already held by the class, and returns the result.

@return [Hash]

The merged set of options, returned as a hash.

@param [Options] options

An {Options}-derived class containing a set of options to use if this
instance has no options, or options to add to this one if this
instance already has options.

@param [Hash] extra_to_add

A hash containing extra options to merge with the options held by the
class and those provided in the `options` parameter.
# File lib/aws/decider/options.rb, line 72
def get_options(options, extra_to_add = {})
  options = self.class.held_properties.compact if options.empty?

  set_options = options.select do |option|
    self.send(option) != nil && self.send(option) != ""
  end

  option_values = set_options.map do |option|
    self.send(option) == Float::INFINITY ? "NONE" : self.send(option)
  end

  result = Hash[set_options.zip(option_values)]
  result.merge(extra_to_add)
end
method_missing(method_name, *args, &block) click to toggle source

@api private

# File lib/aws/decider/options.rb, line 34
def method_missing(method_name, *args, &block)
  return nil
end