Class: ChefLicensing::LicenseKeyValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-licensing/license_key_validator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#licenseObject (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.message)
end