Class: Terraframe::Resource
- Inherits:
-
ScriptItem
- Object
- ScriptItem
- Terraframe::Resource
- Defined in:
- lib/terraframe/resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
Attributes inherited from ScriptItem
Instance Method Summary collapse
- #cleanup_provisioner_type(provisioner_type) ⇒ Object
- #connection(&block) ⇒ Object
-
#initialize(resource_name, vars, context, &block) ⇒ Resource
constructor
A new instance of Resource.
- #provisioner(provisioner_type, &block) ⇒ Object
Methods inherited from ScriptItem
#id_of, #method_missing, #output_of, #to_json
Constructor Details
#initialize(resource_name, vars, context, &block) ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 |
# File 'lib/terraframe/resource.rb', line 7 def initialize(resource_name, vars, context, &block) @resource_name = resource_name super(vars, context, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Terraframe::ScriptItem
Instance Attribute Details
#resource_name ⇒ Object (readonly)
Returns the value of attribute resource_name.
5 6 7 |
# File 'lib/terraframe/resource.rb', line 5 def resource_name @resource_name end |
Instance Method Details
#cleanup_provisioner_type(provisioner_type) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/terraframe/resource.rb', line 26 def cleanup_provisioner_type(provisioner_type) case provisioner_type.to_sym when :remote_exec "remote-exec" when :local_exec "local-exec" else provisioner_type end end |
#connection(&block) ⇒ Object
12 13 14 15 |
# File 'lib/terraframe/resource.rb', line 12 def connection(&block) connection_set = Connection.new(vars, context, &block) @fields["connection"] = connection_set.fields end |
#provisioner(provisioner_type, &block) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/terraframe/resource.rb', line 17 def provisioner(provisioner_type, &block) provisioner_type = provisioner_type.to_sym @fields["provisioner"] = @fields["provisioner"] || [] provisioner_set = Provisioner.new(vars, context, &block) @fields["provisioner"] << { cleanup_provisioner_type(provisioner_type) => provisioner_set.fields } end |