Method: Inspec::ControlEvalContext.rule_context

Defined in:
lib/inspec/control_eval_context.rb

.rule_context(resources_dsl, profile_id) ⇒ RuleContext

Create the context for controls. This includes all components of the DSL, including matchers and resources.

Parameters:

  • resources_dsl (ResourcesDSL)

    which has all resources to attach

Returns:

  • (RuleContext)

    the inner context of rules



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/inspec/control_eval_context.rb', line 22

def self.rule_context(resources_dsl, profile_id)
  require 'rspec/core/dsl'
  Class.new(Inspec::Rule) do
    include RSpec::Core::DSL
    with_resource_dsl resources_dsl

    # allow attributes to be accessed within control blocks
    define_method :attribute do |name|
      Inspec::AttributeRegistry.find_attribute(name, profile_id).value
    end
  end
end