mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
Accept a refactornig suggestion
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
835bd2be8c
commit
3a97e5d75b
1 changed files with 7 additions and 16 deletions
|
@ -78,27 +78,18 @@ module Inspec
|
|||
# Return FalseClass if the update contained no useful information
|
||||
# and a retry should not be attempted
|
||||
def update_from_opts(opts)
|
||||
changed = false
|
||||
|
||||
old_val = @archive_shasum
|
||||
new_val = opts[:sha256]
|
||||
unless old_val == new_val
|
||||
@archive_shasum = new_val
|
||||
changed = true
|
||||
end
|
||||
|
||||
changed = @archive_shasum != opts[:sha256]
|
||||
@archive_shasum = opts[:sha256]
|
||||
changed
|
||||
end
|
||||
|
||||
# Helper for above.
|
||||
# Helper for above; usful when the subclass ivars whose
|
||||
# names exactly match the names of the fetcher options.
|
||||
def update_ivar_from_opt(opt_name, opts)
|
||||
ivar_sym = "@#{opt_name}".to_sym
|
||||
old_val = instance_variable_get(ivar_sym)
|
||||
new_val = opts[opt_name]
|
||||
return false if old_val == new_val
|
||||
|
||||
instance_variable_set(ivar_sym, new_val)
|
||||
true
|
||||
changed = instance_variable_get(ivar_sym) != opts[opt_name]
|
||||
instance_variable_set(ivar_sym, opts[opt_name])
|
||||
changed
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue