Module: Omega::Server::CommandHelpers

Overview

Convencience methods which commands may include to simplify operations

Instance Method Summary collapse

Instance Method Details

#invoke(*args) ⇒ Object

invoke a command via the node


163
164
165
# File 'lib/omega/server/command.rb', line 163

def invoke(*args)
  node.invoke *args
end

#retrieve(entity_id) ⇒ Object

retrieve entity from registry


150
151
152
# File 'lib/omega/server/command.rb', line 150

def retrieve(entity_id)
  registry.entity { |e| e.respond_to?(:id) && e.id == entity_id }
end

#run_callbacks(entity, *args) ⇒ Object

run callbacks with args on the registry entity


155
156
157
158
159
160
# File 'lib/omega/server/command.rb', line 155

def run_callbacks(entity, *args)
  registry.safe_exec { |entities|
    e = entities.find { |e| e.respond_to?(:id) && e.id == entity.id }
    e.run_callbacks *args
  }
end

#update_registry(entity) ⇒ Object

update entity in registry


145
146
147
# File 'lib/omega/server/command.rb', line 145

def update_registry(entity)
  registry.update(entity) { |e| e.respond_to?(:id) && e.id == entity.id }
end