Class: Chef::ActionCollection::ActionRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/action_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_resource, action, nesting_level) ⇒ ActionRecord

Returns a new instance of ActionRecord.


75
76
77
78
79
# File 'lib/chef/action_collection.rb', line 75

def initialize(new_resource, action, nesting_level)
  @new_resource = new_resource
  @action = action
  @nesting_level = nesting_level
end

Instance Attribute Details

#actionSymbol

Returns # The action that was run (or scheduled to run in the case of "unprocessed" resources).

Returns:

  • (Symbol)

    The action that was run (or scheduled to run in the case of "unprocessed" resources).


42
43
44
# File 'lib/chef/action_collection.rb', line 42

def action
  @action
end

#after_resourceChef::Resource

non custom-resources or resources that do not implement load_after_resource.

Returns:

  • (Chef::Resource)

    the after_resource object (after-state). This can be nil for


39
40
41
# File 'lib/chef/action_collection.rb', line 39

def after_resource
  @after_resource
end

#conditionalChef::Resource::Conditional

Returns The conditional that caused the resource to be skipped.

Returns:


54
55
56
# File 'lib/chef/action_collection.rb', line 54

def conditional
  @conditional
end

#current_resourceChef::Resource

for non-why-run-safe resources in why-run mode, or if load_current_resource itself threw an exception (which should be considered a bug in that load_current_resource implementation, but must be handled), or for unprocessed resources.

Returns:

  • (Chef::Resource)

    The current_resource object (before-state). This can be nil


35
36
37
# File 'lib/chef/action_collection.rb', line 35

def current_resource
  @current_resource
end

#elapsed_timeNumeric

Returns The elapsed time in seconds with machine precision.

Returns:

  • (Numeric)

    The elapsed time in seconds with machine precision


51
52
53
# File 'lib/chef/action_collection.rb', line 51

def elapsed_time
  @elapsed_time
end

#error_descriptionHash

Returns JSON-formatted error description from the Chef::Formatters::ErrorMapper.

Returns:

  • (Hash)

    JSON-formatted error description from the Chef::Formatters::ErrorMapper


48
49
50
# File 'lib/chef/action_collection.rb', line 48

def error_description
  @error_description
end

#exceptionException

Returns The exception that was thrown.

Returns:

  • (Exception)

    The exception that was thrown


45
46
47
# File 'lib/chef/action_collection.rb', line 45

def exception
  @exception
end

#nesting_levelInteger

The "nesting" level. Outer resources in recipe context are 0 here, while for every sub-resource_collection inside of a custom resource this number is incremented by 1. Resources that are fired via build-resource or manually creating and firing

Returns:

  • (Integer)

73
74
75
# File 'lib/chef/action_collection.rb', line 73

def nesting_level
  @nesting_level
end

#new_resourceChef::Resource

Returns The declared resource state.

Returns:


29
30
31
# File 'lib/chef/action_collection.rb', line 29

def new_resource
  @new_resource
end

#statusSymbol

The status of the resource:

  • updated: ran and converged
  • up_to_date: skipped due to idempotency
  • skipped: skipped due to a conditional
  • failed: failed with an exception
  • unprocessed: resources that were not touched by a run that failed

Returns:


65
66
67
# File 'lib/chef/action_collection.rb', line 65

def status
  @status
end

Instance Method Details

#success?Boolean

Returns true if there was no exception.

Returns:

  • (Boolean)

    true if there was no exception


82
83
84
# File 'lib/chef/action_collection.rb', line 82

def success?
  !exception
end