Method: Inspec::ProfileContext#register_rule

Defined in:
lib/inspec/profile_context.rb

#register_rule(r) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/inspec/profile_context.rb', line 44

def register_rule(r)
  # get the full ID
  r.instance_variable_set(:@__file, @current_load[:file])
  r.instance_variable_set(:@__group_title, @current_load[:title])
  full_id = Inspec::Rule.full_id(@profile_id, r)
  if full_id.nil?
    # TODO: error
    return
  end

  # add the rule to the registry
  existing = @rules[full_id]
  if existing.nil?
    @rules[full_id] = r
  else
    Inspec::Rule.merge(existing, r)
  end
end