module AWS::Flow::Templates
@api private
Public Class Methods
Initializes an activity template @param {String} name @param {Hash} options
# File lib/aws/templates/activity.rb, line 63 def self.activity(name, opts = {}) ActivityTemplate.new(name, opts) end
Returns the default workflow class @api private
# File lib/aws/templates/default.rb, line 143 def self.default_workflow return AWS::Flow::Templates.const_get(FlowConstants.defaults[:prefix_name]) end
Used to convert a regular ruby class into a Ruby Flow
Activity
class, i.e. extends the AWS::Flow::Activities
module. It converts all user defined instance methods into activities and assigns the following defaults to the ActivityType
- version: “1.0”
# File lib/aws/templates/default.rb, line 60 def self.make_activity_class(klass) return klass if klass.nil? name = klass.name.split(":").last proxy_name = name + "Proxy" # Create a proxy activity class that will define activities for all # instance methods of the class. new_klass = self::ActivityProxies.const_set(proxy_name.to_sym, Class.new(Object)) # Extend the AWS::Flow::Activities module and create activities for all # instance methods new_klass.class_exec do extend AWS::Flow::Activities attr_reader :instance @@klass = klass def initialize @instance = @@klass.new end # Creates activities for all instance methods of the held klass @@klass.instance_methods(false).each do |method| activity(method) do { version: "1.0", prefix_name: name } end end # Redirect all method calls to the held instance def method_missing(method, *args, &block) @instance.send(method, *args, &block) end end new_klass end
# File lib/aws/templates/default.rb, line 79 def initialize @instance = @@klass.new end
Initializes a result activity template @param {String} key
A unique key that identifies the result of an activity execution
@param {Hash} options
# File lib/aws/templates/activity.rb, line 103 def self.result(key, opts = {}) ResultActivityTemplate.new(key, opts) end
Returns the default result activity class @api private
# File lib/aws/templates/default.rb, line 137 def self.result_activity return AWS::Flow::Templates.const_get(FlowConstants.defaults[:result_activity_prefix]) end
Initializes a root template @param {TemplateBase} step
An AWS Flow Framework Template class that inherits TemplateBase. It contains the actual orchestration of workflow logic inside it.
@param {ActivityTemplate} result_step
An optional ActivityTemplate that can be used to report the result of the 'step'
# File lib/aws/templates/base.rb, line 80 def self.root(step, result_step = nil) RootTemplate.new(step, result_step) end
Public Instance Methods
Initializes an activity template @param {String} name @param {Hash} options
# File lib/aws/templates/activity.rb, line 56 def activity(name, opts = {}) AWS::Flow::Templates.send(:activity, name, opts) end
Redirect all method calls to the held instance
# File lib/aws/templates/default.rb, line 94 def method_missing(method, *args, &block) @instance.send(method, *args, &block) end
Initializes a result activity template @param {String} key
A unique key that identifies the result of an activity execution
@param {Hash} options
# File lib/aws/templates/activity.rb, line 95 def result(key, opts = {}) AWS::Flow::Templates.send(:result, key, opts) end
Initializes a root template @param {TemplateBase} step
An AWS Flow Framework Template class that inherits TemplateBase. It contains the actual orchestration of workflow logic inside it.
@param {ActivityTemplate} result_step
An optional ActivityTemplate that can be used to report the result of the 'step'
# File lib/aws/templates/base.rb, line 69 def root(step, result_step = nil) AWS::Flow::Templates.send(:root, step, result_step) end