ananace / fog-hyperv

Hyper-V provider for fog
MIT License
8 stars 1 forks source link

Don't pass around option hashes all over the place #4

Open ananace opened 7 years ago

ananace commented 7 years ago

All the methods need to get some better - and more descriptive - input fields instead.

For instance, perhaps Server could have its power off method split into multiples;

def turn_off
  requires :name, :computer_name
  service.stop_vm name: name,
                  computer_name: computer_name,
                  turn_off: true
end

def stop(force = false)
  requires :name, :computer_name
  service.stop_vm name: name,
                  computer_name: computer_name,
                  force: force
end

Or just simplifying down slightly;

def stop(method = nil)
  requires :name, :computer_name
  args = {
    name: name,
    computer_name: computer_name
  }
  args[method] = true if [:force, :turn_off].include? method
  service.stop_vm args
end