Class: Chef::Resource::Notification
- Inherits:
-
Struct
- Object
- Struct
- Chef::Resource::Notification
- Defined in:
- lib/chef/resource.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#notifying_resource ⇒ Object
Returns the value of attribute notifying_resource.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #duplicates?(other_notification) ⇒ Boolean
- #resolve_resource_reference(resource_collection) ⇒ Object
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
32 33 34 |
# File 'lib/chef/resource.rb', line 32 def action @action end |
#notifying_resource ⇒ Object
Returns the value of attribute notifying_resource
32 33 34 |
# File 'lib/chef/resource.rb', line 32 def end |
#resource ⇒ Object
Returns the value of attribute resource
32 33 34 |
# File 'lib/chef/resource.rb', line 32 def resource @resource end |
Instance Method Details
#duplicates?(other_notification) ⇒ Boolean
34 35 36 37 38 39 40 41 |
# File 'lib/chef/resource.rb', line 34 def duplicates?(other_notification) unless other_notification.respond_to?(:resource) && other_notification.respond_to?(:action) msg = "only duck-types of Chef::Resource::Notification can be checked for duplication "\ "you gave #{other_notification.inspect}" raise ArgumentError, msg end other_notification.resource == resource && other_notification.action == action end |
#resolve_resource_reference(resource_collection) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/resource.rb', line 43 def resolve_resource_reference(resource_collection) return resource if resource.kind_of?(Chef::Resource) matching_resource = resource_collection.find(resource) if Array(matching_resource).size > 1 msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple resources, "\ "but can only notify one resource. Notifying resource was defined on #{notifying_resource.source_line}" raise Chef::Exceptions::InvalidResourceReference, msg end self.resource = matching_resource rescue Chef::Exceptions::ResourceNotFound => e err = Chef::Exceptions::ResourceNotFound.new("Resource \#{notifying_resource} is configured to notify resource \#{resource} with action \#{action}, \\\nbut \#{resource} cannot be found in the resource collection. \#{notifying_resource} is defined in \\\n\#{notifying_resource.source_line}\n") err.set_backtrace(e.backtrace) raise err rescue Chef::Exceptions::InvalidResourceSpecification => e err = Chef::Exceptions::InvalidResourceSpecification.new("Resource \#{notifying_resource} is configured to notify resource \#{resource} with action \#{action}, \\\nbut \#{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \\\nis defined near \#{notifying_resource.source_line}\n") err.set_backtrace(e.backtrace) raise err end |