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.


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

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

Instance Attribute Details

#asyncObject (readonly)

Returns the value of attribute async


5
6
7
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 5

def async
  @async
end

#working_dirObject (readonly)

Returns the value of attribute working_dir


5
6
7
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 5

def working_dir
  @working_dir
end

Instance Method Details

#connection_nameObject


12
13
14
# File 'lib/remote_ruby/connection_adapter/eval_adapter.rb', line 12

def connection_name
  ''
end

#open(code) ⇒ Object


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

def open(code)
  if async
    run_async(code) do |out, err|
      yield out, err
    end
  else
    run_sync(code) do |out, err|
      yield out, err
    end
  end
end