class Aggro::Handler::Command

Private: Handler for incoming command requests.

Public Instance Methods

call() click to toggle source
# File lib/aggro/handler/command.rb, line 5
def call
  commandee_local? ? handle_local : handle_foreign
end

Private Instance Methods

channel() click to toggle source
# File lib/aggro/handler/command.rb, line 11
def channel
  Aggro.channels[commandee_id]
end
comandee_locator() click to toggle source
# File lib/aggro/handler/command.rb, line 31
def comandee_locator
  @comandee_locator ||= Locator.new(commandee_id)
end
command() click to toggle source
# File lib/aggro/handler/command.rb, line 15
def command
  @command ||= message.to_command
end
command_known?() click to toggle source
# File lib/aggro/handler/command.rb, line 23
def command_known?
  !command.nil?
end
commandee_id() click to toggle source
# File lib/aggro/handler/command.rb, line 19
def commandee_id
  message.commandee_id
end
commandee_local?() click to toggle source
# File lib/aggro/handler/command.rb, line 27
def commandee_local?
  comandee_locator.local?
end
handle_foreign() click to toggle source
# File lib/aggro/handler/command.rb, line 35
def handle_foreign
  comandee_locator.primary_node.client.post message
end
handle_known() click to toggle source
# File lib/aggro/handler/command.rb, line 39
def handle_known
  if channel.handles_command?(command)
    channel.forward_command command

    Message::OK.new
  else
    Message::UnhandledOperation.new
  end
rescue NoMethodError
  Message::InvalidTarget.new
end
handle_local() click to toggle source
# File lib/aggro/handler/command.rb, line 51
def handle_local
  command_known? ? handle_known : handle_unknown
end
handle_unknown() click to toggle source
# File lib/aggro/handler/command.rb, line 55
def handle_unknown
  Message::UnknownOperation.new
end