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.



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

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

#conditionalChef::Resource::Conditional

Returns The conditional that caused the resource to be skipped.

Returns:



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

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



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

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



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

def elapsed_time
  @elapsed_time
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)


70
71
72
# File 'lib/chef/action_collection.rb', line 70

def nesting_level
  @nesting_level
end

#new_resourceChef::Resource

XXX: this is buggy since we (ab)use this resource for “after” state and it may be inaccurate and it may be mutated by the user. A third after_resource should be added to new_resource + current_resource to properly implement this.

Returns:



33
34
35
# File 'lib/chef/action_collection.rb', line 33

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:



62
63
64
# File 'lib/chef/action_collection.rb', line 62

def status
  @status
end

Instance Method Details

#success?Boolean

Returns true if there was no exception.

Returns:

  • (Boolean)

    true if there was no exception



79
80
81
# File 'lib/chef/action_collection.rb', line 79

def success?
  !exception
end