Class: Inspec::DescribeBase

Inherits:
Object
  • Object
show all
Includes:
InputDslHelpers
Defined in:
lib/inspec/describe_base.rb

Instance Method Summary collapse

Methods included from InputDslHelpers

#input_with_profile_id

Constructor Details

#initialize(action) ⇒ DescribeBase

Returns a new instance of DescribeBase.



8
9
10
11
# File 'lib/inspec/describe_base.rb', line 8

def initialize(action)
  @action = action
  @checks = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments) ⇒ Object



33
34
35
# File 'lib/inspec/describe_base.rb', line 33

def method_missing(method_name, *arguments)
  Inspec::DSL.method_missing_resource(inspec, method_name, *arguments)
end

Instance Method Details

#describe(*args, &block) ⇒ Object



37
38
39
# File 'lib/inspec/describe_base.rb', line 37

def describe(*args, &block)
  @checks.push(["describe", args, block])
end

#input(input_name, options = {}) ⇒ Object



25
26
27
# File 'lib/inspec/describe_base.rb', line 25

def input(input_name, options = {})
  input_with_profile_id(__profile_id, input_name, options)
end

#input_object(name) ⇒ Object



29
30
31
# File 'lib/inspec/describe_base.rb', line 29

def input_object(name)
  Inspec::InputRegistry.find_or_register_input(name, __profile_id)
end

#one(&block) ⇒ nil

Evaluate the given block and collect all checks. These will be registered with the callback function under the ‘describe.one’ name.

Parameters:

  • ruby (Proc)

    block containing checks (e.g. via describe)

Returns:

  • (nil)


18
19
20
21
22
23
# File 'lib/inspec/describe_base.rb', line 18

def one(&block)
  return unless block_given?

  instance_eval(&block)
  @action.call("describe.one", @checks, nil)
end