Class: Memorb::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/memorb/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Agent

Returns a new instance of Agent.



6
7
8
9
# File 'lib/memorb/agent.rb', line 6

def initialize(id)
  @id = id
  @store = KeyValueStore.new
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/memorb/agent.rb', line 11

def id
  @id
end

Instance Method Details

#fetch(key, &block) ⇒ Object



21
22
23
# File 'lib/memorb/agent.rb', line 21

def fetch(key, &block)
  value_store.fetch(key.hash, &block)
end

#method_storeObject



13
14
15
# File 'lib/memorb/agent.rb', line 13

def method_store
  store.fetch(:methods) { KeyValueStore.new }
end

#value_storeObject



17
18
19
# File 'lib/memorb/agent.rb', line 17

def value_store
  store.fetch(:value) { KeyValueStore.new }
end