Class: RTM::TopicMapManager

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeTopicMapManager

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_mapsObject (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