Class: GraphAgent::Channels::BaseChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_agent/channels/base_channel.rb

Constant Summary collapse

MISSING =
Object.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: "") ⇒ BaseChannel

Returns a new instance of BaseChannel.



10
11
12
# File 'lib/graph_agent/channels/base_channel.rb', line 10

def initialize(key: "")
  @key = key
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



8
9
10
# File 'lib/graph_agent/channels/base_channel.rb', line 8

def key
  @key
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/graph_agent/channels/base_channel.rb', line 32

def available?
  get
  true
rescue EmptyChannelError
  false
end

#checkpointObject



22
23
24
25
26
# File 'lib/graph_agent/channels/base_channel.rb', line 22

def checkpoint
  get
rescue EmptyChannelError
  MISSING
end

#consumeObject



39
40
41
# File 'lib/graph_agent/channels/base_channel.rb', line 39

def consume
  false
end

#copyObject



47
48
49
# File 'lib/graph_agent/channels/base_channel.rb', line 47

def copy
  from_checkpoint(checkpoint)
end

#finishObject



43
44
45
# File 'lib/graph_agent/channels/base_channel.rb', line 43

def finish
  false
end

#from_checkpoint(checkpoint) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/graph_agent/channels/base_channel.rb', line 28

def from_checkpoint(checkpoint)
  raise NotImplementedError.new("#{self.class}#from_checkpoint must be implemented")
end

#getObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/graph_agent/channels/base_channel.rb', line 14

def get
  raise NotImplementedError.new("#{self.class}#get must be implemented")
end

#update(values) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/graph_agent/channels/base_channel.rb', line 18

def update(values)
  raise NotImplementedError.new("#{self.class}#update must be implemented")
end