class Deluge::Api::Namespace

Attributes

api_methods[R]
connection[R]
name[R]
namespaces[R]

Public Class Methods

new(name, connection) click to toggle source
# File lib/deluge/api/namespace.rb, line 6
def initialize(name, connection)
  @name, @connection = name, connection
  @namespaces = {}
  @api_methods = []
end

Public Instance Methods

call(method, *args) click to toggle source
# File lib/deluge/api/namespace.rb, line 38
def call(method, *args)
  method_name = "#{name}.#{method}"

  @connection.call(method_name, *args)
end
register_method(method) click to toggle source
# File lib/deluge/api/namespace.rb, line 28
def register_method(method)
  method = method.to_sym

  api_methods << "#{name}.#{method}"

  define_singleton_method(method) do |*args|
    call(method, *args)
  end
end
register_namespace(namespace) click to toggle source
# File lib/deluge/api/namespace.rb, line 12
def register_namespace(namespace)
  namespace = namespace.to_sym

  return namespaces[namespace] if namespaces.include?(namespace)

  ns = Namespace.new("#{self.name}.#{namespace}", connection)

  namespaces[namespace] = ns

  define_singleton_method(namespace) do
    ns
  end

  ns
end