Class: RemoteRuby::EvalAdapter

Inherits:
ConnectionAdapter show all
Defined in:
lib/remote_ruby/connection_adapter/eval_adapter.rb

Overview

An adapter to expecute Ruby code in the current process in an isolated scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_dir: Dir.pwd, async: false) ⇒ EvalAdapter

Returns a new instance of EvalAdapter.



9
10
11
12
13
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 9

def initialize(working_dir: Dir.pwd, async: false)
  super
  @async = async
  @working_dir = working_dir
end

Instance Attribute Details

#asyncObject (readonly)

Returns the value of attribute async.



7
8
9
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 7

def async
  @async
end

#working_dirObject (readonly)

Returns the value of attribute working_dir.



7
8
9
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 7

def working_dir
  @working_dir
end

Instance Method Details

#connection_nameObject



15
16
17
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 15

def connection_name
  ''
end

#open(code, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 19

def open(code, &block)
  if async
    run_async(code, &block)
  else
    run_sync(code, &block)
  end
end