Class: ChefDK::Policyfile::ComparisonBase::PolicyGroup
- Inherits:
-
Object
- Object
- ChefDK::Policyfile::ComparisonBase::PolicyGroup
- Defined in:
- lib/chef-dk/policyfile/comparison_base.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#policy_name ⇒ Object
readonly
Returns the value of attribute policy_name.
Instance Method Summary collapse
-
#initialize(group, policy_name, http_client) ⇒ PolicyGroup
constructor
A new instance of PolicyGroup.
- #lock ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(group, policy_name, http_client) ⇒ PolicyGroup
Returns a new instance of PolicyGroup.
98 99 100 101 102 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 98 def initialize(group, policy_name, http_client) @group = group @policy_name = policy_name @http_client = http_client end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
94 95 96 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 94 def group @group end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
96 97 98 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 96 def http_client @http_client end |
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
95 96 97 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 95 def policy_name @policy_name end |
Instance Method Details
#lock ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 108 def lock http_client.get("policy_groups/#{group}/policies/#{policy_name}") rescue Net::ProtocolError => e if e.respond_to?(:response) && e.response.code.to_s == "404" raise PolicyfileDownloadError.new("No Policyfile lock named '#{policy_name}' found in policy_group '#{group}' at #{http_client.url}", e) else raise PolicyfileDownloadError.new("HTTP error attempting to fetch Policyfile lock from #{http_client.url}", e) end rescue => e raise PolicyfileDownloadError.new("Failed to fetch Policyfile lock from #{http_client.url}", e) end |
#name ⇒ Object
104 105 106 |
# File 'lib/chef-dk/policyfile/comparison_base.rb', line 104 def name "policy_group:#{group}" end |