Class: Pvectl::Commands::Get::Handlers::Time
- Inherits:
-
Object
- Object
- Pvectl::Commands::Get::Handlers::Time
- Includes:
- ResourceHandler
- Defined in:
- lib/pvectl/commands/get/handlers/time.rb
Overview
Handler for listing node time and timezone settings.
Implements ResourceHandler interface for the “time” resource type. When ‘–node` is supplied, returns the time config for that single node. Otherwise, iterates over all online nodes and aggregates their time configs. Unreachable nodes (those that raise during fetch) are silently skipped so one bad node does not abort the whole listing.
Instance Method Summary collapse
-
#initialize(repository: nil, node_repository: nil) ⇒ Time
constructor
Creates handler with optional repositories for dependency injection.
-
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::TimeConfig>
Lists time/timezone configs.
-
#presenter ⇒ Presenters::TimeConfig
Returns presenter for time configs.
Methods included from ResourceHandler
Constructor Details
#initialize(repository: nil, node_repository: nil) ⇒ Time
Creates handler with optional repositories for dependency injection.
30 31 32 33 |
# File 'lib/pvectl/commands/get/handlers/time.rb', line 30 def initialize(repository: nil, node_repository: nil) @repository = repository @node_repository = node_repository end |
Instance Method Details
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::TimeConfig>
Lists time/timezone configs.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pvectl/commands/get/handlers/time.rb', line 44 def list(node: nil, name: nil, args: [], storage: nil, **) return [fetch_for(node)] if node online_node_names.filter_map do |node_name| begin repository.fetch(node_name) rescue StandardError # Skip unreachable nodes - one bad node should not abort the listing. nil end end end |
#presenter ⇒ Presenters::TimeConfig
Returns presenter for time configs.
60 61 62 |
# File 'lib/pvectl/commands/get/handlers/time.rb', line 60 def presenter Pvectl::Presenters::TimeConfig.new end |