Class: Gienah::Testing::FakeTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/gienah/testing/fake_plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, manifest, receive) ⇒ FakeTransport

Returns a new instance of FakeTransport.



55
56
57
58
59
60
61
# File 'lib/gienah/testing/fake_plugin.rb', line 55

def initialize(plugin, manifest, receive)
  @plugin = plugin
  @manifest = manifest
  @receive = receive
  @pid = Process.pid
  @closed = false
end

Instance Attribute Details

#pid ⇒ Object (readonly)

Returns the value of attribute pid.



53
54
55
# File 'lib/gienah/testing/fake_plugin.rb', line 53

def pid
  @pid
end

Instance Method Details

#alive? ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/gienah/testing/fake_plugin.rb', line 70

def alive?
  !@closed
end

#close ⇒ Object



74
75
76
77
# File 'lib/gienah/testing/fake_plugin.rb', line 74

def close(**)
  @closed = true
  true
end

#write(message) ⇒ Object

Raises:



63
64
65
66
67
68
# File 'lib/gienah/testing/fake_plugin.rb', line 63

def write(message, **)
  raise Error, "transport is closed" if @closed
  response = @plugin.dispatch(message)
  @receive.call(response, nil) if response
  nil
end