class Atheme::Service

Attributes

raw_services_output[R]

Public Class Methods

create_service_object(method, service, atheme_data) click to toggle source
# File lib/atheme/service.rb, line 12
def self.create_service_object(method, service, atheme_data)
  if parser_for?(service, method)
    parser = Atheme::Support.constantize("Atheme::Parser::#{service}::#{method.capitalize}")

    self.new(atheme_data).extend(parser)
  else
    self.new(atheme_data)
  end
end
inherited(klass) click to toggle source
# File lib/atheme/service.rb, line 8
def self.inherited(klass)
  Atheme::SERVICES << klass.name.gsub('Atheme::', '')
end
method_missing(method, *args, &block) click to toggle source
# File lib/atheme/service.rb, line 22
def self.method_missing(method, *args, &block)
  raise Atheme::Error::InvalidUser, 'No user has been set' if Atheme.user.nil?

  service = self.name.gsub('Atheme::', '')

  self.create_service_object(method, service, Atheme.call('atheme.command',
    Atheme.user.cookie, Atheme.user.username, Atheme.user.ip,
    service, method, *args))
end
new(output) click to toggle source
# File lib/atheme/service.rb, line 4
def initialize(output)
  @raw_services_output = output
end
parser_for?(service, command) click to toggle source
# File lib/atheme/service.rb, line 32
def self.parser_for?(service, command)
  if Atheme::PARSERS.include?(service)
    Atheme::PARSERS[service].include?(command.to_s)
  else
    false
  end
end