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.



122
123
124
# File 'lib/wakame/agent.rb', line 122

def initialize()
  @actors = {}
end

Instance Attribute Details

#actorsObject (readonly)

Returns the value of attribute actors.



121
122
123
# File 'lib/wakame/agent.rb', line 121

def actors
  @actors
end

Instance Method Details

#find_actor(path) ⇒ Object



145
146
147
# File 'lib/wakame/agent.rb', line 145

def find_actor(path)
  @actors[path]
end

#register(actor, path = nil) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/wakame/agent.rb', line 126

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



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

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