Class: VagrantPlugins::SshConfigManager::Action::Reload

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ssh-config-manager/action/reload.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Reload

Returns a new instance of Reload.



5
6
7
8
9
# File 'lib/vagrant-ssh-config-manager/action/reload.rb', line 5

def initialize(app, env)
  @app = app
  @env = env
  @logger = Log4r::Logger.new("vagrant::plugins::ssh_config_manager::action::reload")
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-ssh-config-manager/action/reload.rb', line 11

def call(env)
  # Call the next middleware first
  @app.call(env)

  # Only proceed if the machine is running and SSH is ready
  machine = env[:machine]
  return unless machine && machine.state.id == :running

  # Check if plugin is enabled
  config = machine.config.sshconfigmanager
  return unless config && config.enabled

  # Handle SSH config update
  handle_ssh_config_update(machine, config)
end