Class: Memorb::Agent
- Inherits:
-
Object
- Object
- Memorb::Agent
- Defined in:
- lib/memorb/agent.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #fetch(key, &block) ⇒ Object
-
#initialize(id) ⇒ Agent
constructor
A new instance of Agent.
- #method_store ⇒ Object
- #value_store ⇒ Object
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
#id ⇒ Object (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_store ⇒ Object
13 14 15 |
# File 'lib/memorb/agent.rb', line 13 def method_store store.fetch(:methods) { KeyValueStore.new } end |
#value_store ⇒ Object
17 18 19 |
# File 'lib/memorb/agent.rb', line 17 def value_store store.fetch(:value) { KeyValueStore.new } end |