Method: Rbeapi::Client::Node#api

Defined in:
lib/rbeapi/client.rb

#api(name, opts = {}) ⇒ Object

Returns an API module for working with the active configuration of the node.



540
541
542
543
544
545
546
547
548
# File 'lib/rbeapi/client.rb', line 540

def api(name, opts = {})
  path = opts.fetch(:path, 'rbeapi/api')
  namespace = opts.fetch(:namespace, 'Rbeapi::Api')
  require "#{path}/#{name}"
  clsname = "#{namespace}::#{name.capitalize}"
  cls = Rbeapi::Utils.class_from_string(clsname)
  return cls.instance(self) if cls.respond_to?(:instance)
  cls.new(self)
end