Method: Inspec::Rule.merge

Defined in:
lib/inspec/rule.rb

.merge(dst, src) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/inspec/rule.rb', line 79

def self.merge(dst, src)
  if src.id != dst.id
    # TODO: register an error, this case should not happen
    return
  end
  sp = src.instance_variable_get(:@profile_id)
  dp = dst.instance_variable_get(:@profile_id)
  if sp != dp
    # TODO: register an error, this case should not happen
    return
  end
  # merge all fields
  dst.impact(src.impact) unless src.impact.nil?
  dst.title(src.title)   unless src.title.nil?
  dst.desc(src.desc)     unless src.desc.nil?
  # merge indirect fields
  # checks defined in the source will completely eliminate
  # all checks that were defined in the destination
  sc = src.instance_variable_get(:@checks)
  unless sc.nil? || sc.empty?
    dst.instance_variable_set(:@checks, sc)
  end
end