Simplify if-statement in trigger parser
This commit is contained in:
parent
659aa1c48e
commit
fc4e6e624f
|
@ -44,13 +44,15 @@ module VagrantPlugins
|
||||||
command.flatten!
|
command.flatten!
|
||||||
blk = block
|
blk = block
|
||||||
|
|
||||||
if block_given? && command.last.is_a?(Hash)
|
if command.last.is_a?(Hash)
|
||||||
extra_cfg = command.pop
|
if block_given?
|
||||||
elsif !block_given? && command.last.is_a?(Hash)
|
extra_cfg = command.pop
|
||||||
# We were given a hash rather than a block,
|
else
|
||||||
# so the last element should be the "config block"
|
# We were given a hash rather than a block,
|
||||||
# and the rest are commands for the trigger
|
# so the last element should be the "config block"
|
||||||
blk = command.pop
|
# and the rest are commands for the trigger
|
||||||
|
blk = command.pop
|
||||||
|
end
|
||||||
elsif !block_given?
|
elsif !block_given?
|
||||||
raise Vagrant::Errors::TriggersNoBlockGiven,
|
raise Vagrant::Errors::TriggersNoBlockGiven,
|
||||||
command: command
|
command: command
|
||||||
|
@ -71,13 +73,15 @@ module VagrantPlugins
|
||||||
command.flatten!
|
command.flatten!
|
||||||
blk = block
|
blk = block
|
||||||
|
|
||||||
if block_given? && command.last.is_a?(Hash)
|
if command.last.is_a?(Hash)
|
||||||
extra_cfg = command.pop
|
if block_given?
|
||||||
elsif !block_given? && command.last.is_a?(Hash)
|
extra_cfg = command.pop
|
||||||
# We were given a hash rather than a block,
|
else
|
||||||
# so the last element should be the "config block"
|
# We were given a hash rather than a block,
|
||||||
# and the rest are commands for the trigger
|
# so the last element should be the "config block"
|
||||||
blk = command.pop
|
# and the rest are commands for the trigger
|
||||||
|
blk = command.pop
|
||||||
|
end
|
||||||
elsif !block_given?
|
elsif !block_given?
|
||||||
raise Vagrant::Errors::TriggersNoBlockGiven,
|
raise Vagrant::Errors::TriggersNoBlockGiven,
|
||||||
command: command
|
command: command
|
||||||
|
|
Loading…
Reference in New Issue