Class: Wakame::ActorRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/wakame/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActorRegistry

Returns a new instance of ActorRegistry.



119
120
121
# File 'lib/wakame/agent.rb', line 119

def initialize()
  @actors = {}
end

Instance Attribute Details

#actorsObject (readonly)

Returns the value of attribute actors.



118
119
120
# File 'lib/wakame/agent.rb', line 118

def actors
  @actors
end

Instance Method Details

#find_actor(path) ⇒ Object



142
143
144
# File 'lib/wakame/agent.rb', line 142

def find_actor(path)
  @actors[path]
end

#register(actor, path = nil) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/wakame/agent.rb', line 123

def register(actor, path=nil)
  raise '' unless actor.kind_of?(Wakame::Actor)

  if path.nil?
    path = '/' + Util.to_const_path(actor.class.to_s)
  end

  if @actors.has_key?(path)
    Wakame.log.error("#{self.class}: Duplicate registration: #{path}")
    raise "Duplicate registration: #{path}"
  end
  
  @actors[path] = actor
end

#unregister(path) ⇒ Object



138
139
140
# File 'lib/wakame/agent.rb', line 138

def unregister(path)
  @actors.delete(path)
end