Module: Pvectl::Commands::Top::ResourceHandler Abstract

Included in:
Handlers::Containers, Handlers::Nodes, Handlers::Vms
Defined in:
lib/pvectl/commands/top/resource_handler.rb

Overview

This module is abstract.

Include in handler class and implement required methods.

Interface module for Top command handlers.

Each handler wraps a Get handler and returns a Top-specific presenter for metrics-focused display (CPU%, MEM%, etc.).

Examples:

Implementing a handler

class NodesHandler
  include Top::ResourceHandler

  def list(sort: nil, **_)
    get_handler.list(sort: sort)
  end

  def presenter
    Presenters::TopNode.new
  end
end

Instance Method Summary collapse

Instance Method Details

#list(**options) ⇒ Array<Object>

Lists resources with optional sorting.

Parameters:

  • options (Hash)

    keyword arguments (e.g., sort:)

Returns:

  • (Array<Object>)

    collection of model objects

Raises:

  • (NotImplementedError)

    if not implemented by including class



32
33
34
# File 'lib/pvectl/commands/top/resource_handler.rb', line 32

def list(**options)
  raise NotImplementedError, "#{self.class}#list must be implemented"
end

#presenterPresenters::Base

Returns the Top-specific presenter for this resource type.

Returns:

Raises:

  • (NotImplementedError)

    if not implemented by including class



40
41
42
# File 'lib/pvectl/commands/top/resource_handler.rb', line 40

def presenter
  raise NotImplementedError, "#{self.class}#presenter must be implemented"
end