class DTK::Client::Execute::ExecuteContext::Proxy

commands in the execute context

Constants

DelimitersObjectTypeMethod

Public Class Methods

new() click to toggle source
# File lib/execute/execute_context.rb, line 48
def initialize()
  @result_store = ResultStore.new()
end

Public Instance Methods

call(object_type__method,params={}) click to toggle source
# File lib/execute/execute_context.rb, line 52
def call(object_type__method,params={})
  object_type, method = split_object_type__method(object_type__method)
  api_command = Command::APICall.new(:object_type => object_type, :method => method, :params => params)
  result = nil
  api_command.raw_executable_commands() do |raw_command|
    last_result = @result_store.get_last_result?()
    command = raw_command.translate(params,:last_result => last_result)
    result = CommandProcessor.execute(command)
    @result_store.store(result)
  end
  [result, api_command]
end
post_rest_call(path,body={}) click to toggle source
# File lib/execute/execute_context.rb, line 65
def post_rest_call(path,body={})
  command = Command::RestCall::Post.new(:path => path, :body => body, :last_result => @last_result)
  result = CommandProcessor.execute(command)
  [result, command]
end

Private Instance Methods

split_object_type__method(str) click to toggle source

returns [object_type, method]

# File lib/execute/execute_context.rb, line 73
def split_object_type__method(str)
  DelimitersObjectTypeMethod.each do |d| 
    if str =~ Regexp.new("(^[^#{d}]+)#{d}([^#{d}]+$)") 
      return [$1,$2]
    end
  end
  raise ErrorUsage.new("Illegal term '#{str}'")
end