class SimplerWorkflow::Domain
Public Class Methods
[](domain_name)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 20 def Domain.[](domain_name) Domain.domains(domain_name.to_sym) end
domains(domain_name, retention_period = 2, &block)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 13 def Domain.domains(domain_name, retention_period = 2, &block) @domains ||= {} @domains[domain_name] ||= Domain.new(domain_name, retention_period) @domains[domain_name].instance_eval(&block) if block_given? @domains[domain_name] end
for(domain)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 24 def Domain.for(domain) case domain when String, Symbol Domain[domain] when Domain domain when AWS::SimpleWorkflow::Domain Domain[domain.name] end end
new(domain_name, retention_period = 2, &block)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 3 def initialize(domain_name, retention_period = 2, &block) domain_name = domain_name.to_s @domain = swf.domains[domain_name] unless @domain.exists? @domain = swf.domains.create(domain_name, retention_period) rescue @domain end self.instance_eval(&block) if block_given? end
Public Instance Methods
activities()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 61 def activities Activity end
activity_types()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 65 def activity_types domain.activity_types end
method_missing(meth_name, *args)
click to toggle source
Calls superclass method
# File lib/simpler_workflow/domain.rb, line 86 def method_missing(meth_name, *args) if domain.respond_to?(meth_name.to_sym) domain.send(meth_name.to_sym, *args) else super end end
register_activity(name, version = nil, &block)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 69 def register_activity(name, version = nil, &block) logger.info("Registering Activity[#{name},#{version}]") activity = activities[self, name, version] activity.instance_eval(&block) if block activity.persist_attributes begin self.domain.activity_types.register(name.to_s, version, activity.options) rescue ::AWS::SimpleWorkflow::Errors::TypeAlreadyExistsFault SimplerWorkflow.logger.info("Activity[#{name}, #{version}] already registered with SWF.") end activity end
register_workflow(name, version, &block)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 35 def register_workflow(name, version, &block) unless workflow = Workflow[name, version] workflow = Workflow.new(self, name, version) workflow.instance_eval(&block) if block_given? begin self.domain.workflow_types.register(name, version, workflow.options) rescue ::AWS::SimpleWorkflow::Errors::TypeAlreadyExistsFault # Instance already registered... end end workflow end
start_workflow(name, version, input)
click to toggle source
# File lib/simpler_workflow/domain.rb, line 55 def start_workflow(name, version, input) logger.info("Starting workflow[#{name},#{version}]") workflow = Workflow[name, version] || Workflow.new(self, name, version) workflow.start_workflow(input) end
workflows()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 51 def workflows Workflow end
Protected Instance Methods
domain()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 99 def domain @domain end
logger()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 103 def logger $logger || Rails.logger end
swf()
click to toggle source
# File lib/simpler_workflow/domain.rb, line 95 def swf SimplerWorkflow.swf end