Class: Pangea::Contracts::IamResult
- Defined in:
- lib/pangea/contracts/iam_result.rb
Overview
Base typed result object for the IAM phase. Provides named accessors for the core IAM outputs that all providers share.
Provider-specific subclasses (e.g., AWS::IamResult) can add fields like :log_group, :ecr_policy, :karpenter_role via inheritance.
Instance Attribute Summary collapse
-
#instance_profile ⇒ Object
Returns the value of attribute instance_profile.
-
#policies ⇒ Object
Returns the value of attribute policies.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Hash-style access for backward compatibility.
- #dig(*keys) ⇒ Object
-
#initialize ⇒ IamResult
constructor
A new instance of IamResult.
-
#key?(key) ⇒ Boolean
(also: #has_key?, #include?)
Hash-like key checks for backward compatibility with RSpec have_key matcher.
- #to_h ⇒ Object
-
#validate! ⇒ Object
Validate the contract — no required fields for base IAM (some providers have empty IAM).
Constructor Details
#initialize ⇒ IamResult
Returns a new instance of IamResult.
29 30 31 32 33 |
# File 'lib/pangea/contracts/iam_result.rb', line 29 def initialize @role = nil @instance_profile = nil @policies = {} end |
Instance Attribute Details
#instance_profile ⇒ Object
Returns the value of attribute instance_profile.
27 28 29 |
# File 'lib/pangea/contracts/iam_result.rb', line 27 def instance_profile @instance_profile end |
#policies ⇒ Object
Returns the value of attribute policies.
27 28 29 |
# File 'lib/pangea/contracts/iam_result.rb', line 27 def policies @policies end |
#role ⇒ Object
Returns the value of attribute role.
27 28 29 |
# File 'lib/pangea/contracts/iam_result.rb', line 27 def role @role end |
Instance Method Details
#[](key) ⇒ Object
Hash-style access for backward compatibility
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pangea/contracts/iam_result.rb', line 36 def [](key) case key.to_sym when :role then role when :instance_profile then instance_profile when :policies then policies else # Check policies hash for named policy access policies[key.to_sym] end end |
#dig(*keys) ⇒ Object
47 48 49 |
# File 'lib/pangea/contracts/iam_result.rb', line 47 def dig(*keys) to_h.dig(*keys) end |
#key?(key) ⇒ Boolean Also known as: has_key?, include?
Hash-like key checks for backward compatibility with RSpec have_key matcher
52 53 54 |
# File 'lib/pangea/contracts/iam_result.rb', line 52 def key?(key) !self[key].nil? end |
#to_h ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/pangea/contracts/iam_result.rb', line 58 def to_h hash = {} hash[:role] = role if role hash[:instance_profile] = instance_profile if instance_profile policies.each { |k, v| hash[k] = v } unless policies.empty? hash end |
#validate! ⇒ Object
Validate the contract — no required fields for base IAM (some providers have empty IAM).
68 69 70 |
# File 'lib/pangea/contracts/iam_result.rb', line 68 def validate! # No required fields end |