class BuildBox::Response

Attributes

code[RW]
error[RW]
output[RW]
result[RW]

Public Class Methods

new(code, binding_context, security_level, timeout) click to toggle source
# File lib/build_box/response.rb, line 7
def initialize(code, binding_context, security_level, timeout)
  evaluate(code, binding_context, security_level, timeout)
end

Public Instance Methods

error?() click to toggle source
# File lib/build_box/response.rb, line 11
def error?
  !@error.nil?
end

Private Instance Methods

evaluate(code, binding_context, security_level, timeout) click to toggle source
# File lib/build_box/response.rb, line 17
def evaluate(code, binding_context, security_level, timeout)
  preserve_namespace
  result  = BuildBox::Perform.new(code, binding_context, security_level, timeout)
  @output = result.output
  @error  = result.error
  @code   = result.code
  restore_namespace
  self
end
preserve_namespace() click to toggle source
# File lib/build_box/response.rb, line 27
def preserve_namespace
  @old_constants = Object.constants
end
restore_namespace() click to toggle source
# File lib/build_box/response.rb, line 31
def restore_namespace
  (Object.constants - @old_constants).each {|bad_constant| Object.send(:remove_const, bad_constant)}
end