Class: Arrest::IdentityCache
- Inherits:
-
Object
- Object
- Arrest::IdentityCache
- Defined in:
- lib/arrest/transport/request_context.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize ⇒ IdentityCache
constructor
A new instance of IdentityCache.
- #lookup(id, &blk) ⇒ Object
- #remove(id) ⇒ Object
- #update(id, object) ⇒ Object
Constructor Details
#initialize ⇒ IdentityCache
Returns a new instance of IdentityCache.
15 16 17 |
# File 'lib/arrest/transport/request_context.rb', line 15 def initialize() @map = {} end |
Instance Method Details
#flush ⇒ Object
35 36 37 |
# File 'lib/arrest/transport/request_context.rb', line 35 def flush() @map.clear end |
#lookup(id, &blk) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/arrest/transport/request_context.rb', line 19 def lookup(id, &blk) hit = @map[id] unless hit hit = @map[id] = yield end hit.clone end |
#remove(id) ⇒ Object
31 32 33 |
# File 'lib/arrest/transport/request_context.rb', line 31 def remove(id) @map.delete(id) end |
#update(id, object) ⇒ Object
27 28 29 |
# File 'lib/arrest/transport/request_context.rb', line 27 def update(id, object) @map[id] = object end |