Class: Rudder::DSL::Resource
- Defined in:
- lib/rudder/dsl/resource.rb
Overview
Concourse Resource, defines inputs and outputs of a Concourse Job
DSL Usage:
Resource are defined by a name
,
type
, and source
.
Direct Known Subclasses
Instance Method Summary collapse
- #_inner_hash ⇒ Object
-
#initialize(name, type = nil) ⇒ Resource
constructor
All resources require:.
-
#sub_path(child_path) ⇒ String
Useful for creating the full path to a file in a
Resource
without knowing it's underlying concourse name. -
#to_h ⇒ Hash
YAML friendly
Hash
representation of this resource.
Methods inherited from Component
#method_missing, #respond_to?, #respond_to_missing?
Methods included from Util
Constructor Details
#initialize(name, type = nil) ⇒ Resource
All resources require:
-
Name of the resource. Must be unique across resources (not enforcable here).
-
The concourse resource type. Not verified until rendered to a Hash.
49 50 51 52 53 |
# File 'lib/rudder/dsl/resource.rb', line 49 def initialize(name, type = nil) raise super.ArgumentError 'Name cannot be nil' if name.nil? @resource = { name: name, type: type, source: {} } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rudder::DSL::Component
Instance Method Details
#_inner_hash ⇒ Object
77 78 79 |
# File 'lib/rudder/dsl/resource.rb', line 77 def _inner_hash @resource end |
#sub_path(child_path) ⇒ String
Useful for creating the full path to a file in a Resource
without knowing it's underlying concourse name.
61 62 63 |
# File 'lib/rudder/dsl/resource.rb', line 61 def sub_path(child_path) File.join(@resource[:name].to_s, child_path) end |
#to_h ⇒ Hash
Returns YAML friendly Hash
representation of this resource
70 71 72 73 74 75 |
# File 'lib/rudder/dsl/resource.rb', line 70 def to_h raise 'Type must be set for Concourse Resources' if @resource[:type].nil? raise 'Source must be set for Concourse Resources' if @resource[:source].empty? super.to_h end |