Sha256: 44c0aeac45744b016cff4e26ff966c66458a7a634d26bb6a355bb7f5b63a728f

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

require 'auto_network'

class AutoNetwork::Action::LoadPool

  def initialize(app, env)
    @app, @env = app, env
  end

  # Handle the loading and unloading of the auto_network pool
  #
  # @param env [Hash]
  #
  # @option env [AutoNetwork::Pool] auto_network_pool The global auto network pool
  # @option env [Vagrant::Environment] env The Vagrant environment containing
  #   the active machines that need to be filtered.
  #
  # @return [void]
  def call(env)
    @env = env

    if env_ready?
      setup_ivars
      deserialize!
      @app.call(@env)
    else
      @app.call(@env)
    end
  end

  private

  def env_ready?
    !!@env[:home_path]
  end

  def setup_ivars
    @config_path = @env[:home_path].join('auto_network')
    @statefile   = @config_path.join('pool.yaml')
  end

  def deserialize!
    @env[:auto_network_pool] = AutoNetwork::PoolManager.new(@statefile)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-auto_network-1.0.0.beta1 lib/auto_network/action/load_pool.rb