Class: Pangea::Testing::MockResourceReference
- Inherits:
-
Object
- Object
- Pangea::Testing::MockResourceReference
show all
- Defined in:
- lib/pangea/testing/mock_resource_reference.rb
Overview
Mock resource reference for testing. Returns Terraform-style interpolation strings for attribute access (e.g., “$aws_vpcaws_vpc.mainaws_vpc.main.id”).
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(type, name, attributes = {}) ⇒ MockResourceReference
Returns a new instance of MockResourceReference.
24
25
26
27
28
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 24
def initialize(type, name, attributes = {})
@type = type
@name = name
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_args, &_block) ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 54
def method_missing(method_name, *_args, &_block)
if @attributes.key?(method_name)
@attributes[method_name]
elsif @attributes.key?(method_name.to_s)
@attributes[method_name.to_s]
else
"${#{@type}.#{@name}.#{method_name}}"
end
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
22
23
24
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 22
def attributes
@attributes
end
|
Returns the value of attribute name.
22
23
24
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 22
def name
@name
end
|
Returns the value of attribute type.
22
23
24
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 22
def type
@type
end
|
Instance Method Details
34
35
36
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 34
def arn
"${#{@type}.#{@name}.arn}"
end
|
38
39
40
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 38
def email
"${#{@type}.#{@name}.email}"
end
|
42
43
44
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 42
def endpoint
"${#{@type}.#{@name}.endpoint}"
end
|
30
31
32
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 30
def id
"${#{@type}.#{@name}.id}"
end
|
#ipv4_address ⇒ Object
46
47
48
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 46
def ipv4_address
"${#{@type}.#{@name}.ipv4_address}"
end
|
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
65
66
67
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 65
def respond_to_missing?(_method_name, _include_private = false)
true
end
|
50
51
52
|
# File 'lib/pangea/testing/mock_resource_reference.rb', line 50
def to_h
{ type: @type, name: @name, attributes: @attributes }
end
|