Class: Y2Packager::ProductLicense
- Inherits:
-
Object
- Object
- Y2Packager::ProductLicense
- Extended by:
- Forwardable
- Defined in:
- library/packages/src/lib/y2packager/product_license.rb
Overview
This class holds the license stuff for a given product
Why a separate ProductLicense class? First of all, we wanted to extract the license handling from Y2Packager::Product and moving this logic to Y2Packager::License was not a good idea because different products could share the same license. Additionally, this class offers an API to work with licenses when a proper Product or Addon object is not available (backward compatibility reasons).
Instance Attribute Summary collapse
-
#license ⇒ License
readonly
Product's license.
Class Method Summary collapse
-
.clear_cache ⇒ Object
Clear product licenses cache.
-
.find(product_name, content: nil) ⇒ ProductLicense
Find license for a given product.
Instance Method Summary collapse
-
#accept! ⇒ Object
Accept the license.
-
#accepted? ⇒ Boolean
Determine whether the license have been accepted or not.
-
#initialize(product_name, license) ⇒ ProductLicense
constructor
Constructor.
-
#license_confirmation=(confirmed) ⇒ Object
Set the license confirmation for the product.
-
#license_confirmation_required? ⇒ Boolean
Determine whether the license should be accepted or not.
-
#reject! ⇒ Object
Reject the license.
Constructor Details
#initialize(product_name, license) ⇒ ProductLicense
Constructor
78 79 80 81 82 83 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 78 def initialize(product_name, license) @product_name = product_name @license = license @handler = license.handler @fetcher = license.fetcher end |
Instance Attribute Details
#license ⇒ License (readonly)
Returns Product's license.
45 46 47 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 45 def license @license end |
Class Method Details
.clear_cache ⇒ Object
Clear product licenses cache
65 66 67 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 65 def clear_cache @cache = nil end |
.find(product_name, content: nil) ⇒ ProductLicense
Find license for a given product
This method uses a cache to return an already fetched product license.
55 56 57 58 59 60 61 62 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 55 def find(product_name, content: nil) return cache[product_name] if cache[product_name] license = License.find(product_name, content: content) return nil unless license cache[product_name] = ProductLicense.new(product_name, license) end |
Instance Method Details
#accept! ⇒ Object
Accept the license
As a side effect, it will update the license acceptance
96 97 98 99 100 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 96 def accept! license.accept! sync_acceptance nil end |
#accepted? ⇒ Boolean
Determine whether the license have been accepted or not
88 89 90 91 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 88 def accepted? sync_acceptance license.accepted? end |
#license_confirmation=(confirmed) ⇒ Object
Set the license confirmation for the product
42 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 42 def_delegator :@handler, :confirmation= |
#license_confirmation_required? ⇒ Boolean
Determine whether the license should be accepted or not
37 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 37 def_delegator :@fetcher, :confirmation_required? |
#reject! ⇒ Object
Reject the license
103 104 105 106 107 |
# File 'library/packages/src/lib/y2packager/product_license.rb', line 103 def reject! license.reject! sync_acceptance nil end |