Method: Inspec::ProfileContext#register_rule

Defined in:
lib/inspec/profile_context.rb

#register_rule(r) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/inspec/profile_context.rb', line 170

def register_rule(r)
  # get the full ID
  file = if @current_load.nil?
           'unknown'
         else
           @current_load[:file] || 'unknown'
         end
  r.instance_variable_set(:@__file, file)
  r.instance_variable_set(:@__group_title, current_load[:title])

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