lib/runtime/engine.rb in factor-0.0.99 vs lib/runtime/engine.rb in factor-0.1.00

- old
+ new

@@ -29,11 +29,11 @@ def load_channel filename filename = File.absolute_path(File.expand_path(filename.path)) if filename.is_a?(File) # just in case someone passes in a File not a String (i.e. me) require filename channel_module_name = File.basename(filename).gsub('.rb','').split('_').map{|ea| ea.capitalize}.join('') channel_module= self.class.const_get(channel_module_name) - @channel_modules[channel_module.definition["module"]]=channel_module + @channel_modules[channel_module_name]=channel_module end def load_credentials credentials @credentials["credentials"] = credentials end @@ -52,10 +52,11 @@ end end def launch workflow, params instance_id=SecureRandom.hex + @message_bus.start do message = Message.new message.position << "start" message.workflow=workflow message.add_values params @@ -74,28 +75,30 @@ workflow = @workflows[message.workflow] activity = workflow.get_activity(message.position) if !activity.nil? action = activity["action"] channel = activity["channel"] - method = activity["method"] target = activity["target"] + params_template = activity["params"] if match(target) values = message.body.merge(@credentials) # this maps the input values passed in with the templated defined in the workflow #puts "[activity-params] #{activity["params"]}" #puts "[values] #{values}" - params = render_template(activity["params"],values) - #puts "[params] #{params}" + params = render_template(params_template,values) + puts "[rendered params] #{params}" - event = call_channel_method(channel,method,params) + event = call_channel_method(channel,action,params) + # puts "event #{event.inspect}" response_message = message.respond(event.params,event.class.name.split("::").last) + # puts "response #{response_message.inspect}" @message_bus.send response_message end end @@ -112,9 +115,10 @@ end def call_channel_method(channel_name,class_name,params) channel_module = @channel_modules[channel_name] command = channel_module.const_get(class_name) + puts "command: #{command.inspect}" command.new.do_work(params) end private \ No newline at end of file