Class: RTM::TopicMapManager
- Inherits:
-
Object
- Object
- RTM::TopicMapManager
- Defined in:
- lib/rtm/rails.rb
Overview
The TopicMapManager manages TopicMaps by registering a Topic Map using an identifier. The identifier is used to easily access the TopicMap everywhere without passing around the instance manually.
Instance Attribute Summary collapse
-
#topic_maps ⇒ Object
readonly
Returns the value of attribute topic_maps.
Instance Method Summary collapse
- #[](identifier) ⇒ Object
-
#initialize ⇒ TopicMapManager
constructor
A new instance of TopicMapManager.
- #register_map(identifier, map) ⇒ Object
- #remove_map(identifier) ⇒ Object
Constructor Details
#initialize ⇒ TopicMapManager
Returns a new instance of TopicMapManager.
241 242 243 |
# File 'lib/rtm/rails.rb', line 241 def initialize @topic_maps = {} end |
Instance Attribute Details
#topic_maps ⇒ Object (readonly)
Returns the value of attribute topic_maps.
239 240 241 |
# File 'lib/rtm/rails.rb', line 239 def topic_maps @topic_maps end |
Instance Method Details
#[](identifier) ⇒ Object
256 257 258 259 |
# File 'lib/rtm/rails.rb', line 256 def [](identifier) raise "There is no topic map registered with identifier #{identifier.inspect}" unless @topic_maps.keys.include?(identifier) @topic_maps[identifier] end |
#register_map(identifier, map) ⇒ Object
245 246 247 248 249 |
# File 'lib/rtm/rails.rb', line 245 def register_map(identifier, map) raise "A topic map with the identifier #{identifier.inspect} is already registered" if @topic_maps.keys.include?(identifier) # TODO: maybe we should allow to connect here? @topic_maps[identifier] = map end |
#remove_map(identifier) ⇒ Object
251 252 253 254 |
# File 'lib/rtm/rails.rb', line 251 def remove_map(identifier) # TODO: maybe it should be removed from the system here? @topic_maps.delete(identifier) end |