Class: Tempest::REPL::Registry
- Inherits:
-
Object
- Object
- Tempest::REPL::Registry
- Defined in:
- lib/tempest/repl/registry.rb
Overview
Holds two IdVar rings (post + link) plus side tables that resolve a var string back to the original Post / URL. Lifetime is the current REPL session; nothing is persisted.
Instance Method Summary collapse
- #assign_post(post) ⇒ Object
- #assign_url(url) ⇒ Object
- #find_post(var) ⇒ Object
- #find_url(var) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#var_for_uri(uri) ⇒ Object
Reverse lookup: returns the var currently mapped to the given post URI, or nil if the URI has never been assigned or its slot has been recycled to a different post.
Constructor Details
Instance Method Details
#assign_post(post) ⇒ Object
16 17 18 19 20 |
# File 'lib/tempest/repl/registry.rb', line 16 def assign_post(post) var = @post_ids.generate(post_key(post)) @posts[var] = post var end |
#assign_url(url) ⇒ Object
22 23 24 25 26 |
# File 'lib/tempest/repl/registry.rb', line 22 def assign_url(url) var = @link_ids.generate(url) @urls[var] = url var end |
#find_post(var) ⇒ Object
28 29 30 |
# File 'lib/tempest/repl/registry.rb', line 28 def find_post(var) @posts[var] end |
#find_url(var) ⇒ Object
32 33 34 |
# File 'lib/tempest/repl/registry.rb', line 32 def find_url(var) @urls[var] end |
#var_for_uri(uri) ⇒ Object
Reverse lookup: returns the var currently mapped to the given post URI, or nil if the URI has never been assigned or its slot has been recycled to a different post.
39 40 41 42 43 44 |
# File 'lib/tempest/repl/registry.rb', line 39 def var_for_uri(uri) @posts.each do |var, post| return var if post_key(post) == uri end nil end |