Skip to content
Dan Ryan edited this page Sep 13, 2012 · 1 revision

A resource is the resource that the participant modifies. The resource can have a variety of attributes, depending on the participant's needs. The resource performs the majority of validations to ensure the participant has the right fields to execute its actions.

Attributes

Resource attributes vary depending on their purpose.

Example resource

# Modules are used as namespaces.
module Resource::Remote

  # All resources inherit from Resource
  class SSH < Resource
  
    # We'll refer to this resource elsewhere by the name we use to register it.
    register :ssh

    # Various attributes of the resource. The :type option typecasts the attribute.
    attribute :command, :type => String
    attribute :host, :type => String
    attribute :user, :type => String
    attribute :key_data, :type => String  
    attribute :output, :type => String
    
    # Validate the resource to ensure we have the right details.
    validates! :command, :host, :user, :key_data,
      presence: true
  end
end

Clone this wiki locally