lib/workato/connector/sdk/connector.rb in workato-connector-sdk-0.2.0 vs lib/workato/connector/sdk/connector.rb in workato-connector-sdk-0.3.0

- old
+ new

@@ -113,19 +113,22 @@ :object_definitions, :settings def define_action_methods(actions) actions.each do |action, definition| - define_singleton_method(action) do + define_singleton_method(action) do |input_ = nil| @actions ||= {} @actions[action] ||= Action.new( action: definition, object_definitions: object_definitions, methods: methods, connection: connection, settings: settings ) + return @actions[action] if input_.nil? + + @actions[action].invoke(input_) end end end end @@ -219,17 +222,21 @@ :object_definitions, :settings def define_trigger_methods(triggers) triggers.each do |trigger, definition| - define_singleton_method(trigger) do + define_singleton_method(trigger) do |input_ = nil, payload = {}, headers = {}, params = {}| @triggers[trigger] ||= Trigger.new( trigger: definition, object_definitions: object_definitions, methods: methods, connection: connection, settings: settings ) + + return @triggers[trigger] if input_.nil? + + @triggers[trigger].invoke(input_, payload, headers, params) end end end end end