Class: ChefLicensing::LicenseKeyValidator
- Inherits:
-
Object
- Object
- ChefLicensing::LicenseKeyValidator
- Defined in:
- lib/chef-licensing/license_key_validator.rb
Instance Attribute Summary collapse
-
#license ⇒ Object
readonly
Returns the value of attribute license.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(license, restful_client: ChefLicensing::RestfulClient::V1) ⇒ LicenseKeyValidator
constructor
A new instance of LicenseKeyValidator.
- #validate! ⇒ Object
Constructor Details
#initialize(license, restful_client: ChefLicensing::RestfulClient::V1) ⇒ LicenseKeyValidator
Returns a new instance of LicenseKeyValidator.
14 15 16 17 |
# File 'lib/chef-licensing/license_key_validator.rb', line 14 def initialize(license, restful_client: ChefLicensing::RestfulClient::V1) @license = license || raise(ArgumentError, "Missing Params: `license`") @restful_client = restful_client.new end |
Instance Attribute Details
#license ⇒ Object (readonly)
Returns the value of attribute license.
6 7 8 |
# File 'lib/chef-licensing/license_key_validator.rb', line 6 def license @license end |
Class Method Details
.validate!(license) ⇒ Object
9 10 11 |
# File 'lib/chef-licensing/license_key_validator.rb', line 9 def validate!(license) new(license).validate! end |
Instance Method Details
#validate! ⇒ Object
19 20 21 22 |
# File 'lib/chef-licensing/license_key_validator.rb', line 19 def validate! response = @restful_client.validate(license) response.data || raise(ChefLicensing::InvalidLicense, response.) end |