Method: Inspec::ProfileContext#register_rule

Defined in:
lib/inspec/profile_context.rb

#register_rule(r) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/inspec/profile_context.rb', line 156

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