Class: ChefLicensing::Context
- Inherits:
-
Object
- Object
- ChefLicensing::Context
- Defined in:
- lib/chef-licensing/context.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.current_context ⇒ Object
writeonly
Sets the attribute current_context.
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
-
.license(options = {}) ⇒ Object
Return license context object via current context.
-
.license=(license) ⇒ Object
Set license context object via current context Example: ChefLicensing::Context.license = license_context_object.
-
.license_keys(options = {}) ⇒ Object
Return license keys from current context.
- .local_licensing_service? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(state, options = {}) ⇒ Context
constructor
A new instance of Context.
-
#license ⇒ Object
Get license context from local or global state.
-
#license=(license) ⇒ Object
Set license context from local or global state.
-
#license_keys ⇒ Object
The Context delegates part of its behavior to the current State object.
-
#transition_to(state) ⇒ Object
The Context allows changing the State object.
Constructor Details
#initialize(state, options = {}) ⇒ Context
Returns a new instance of Context.
58 59 60 61 62 |
# File 'lib/chef-licensing/context.rb', line 58 def initialize(state, = {}) @options = @logger = ChefLicensing::Config.logger transition_to(state) end |
Class Attribute Details
.current_context=(value) ⇒ Object
Sets the attribute current_context
14 15 16 |
# File 'lib/chef-licensing/context.rb', line 14 def current_context=(value) @current_context = value end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'lib/chef-licensing/context.rb', line 11 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/chef-licensing/context.rb', line 11 def @options end |
#state ⇒ Object
Returns the value of attribute state.
10 11 12 |
# File 'lib/chef-licensing/context.rb', line 10 def state @state end |
Class Method Details
.license(options = {}) ⇒ Object
Return license context object via current context
29 30 31 |
# File 'lib/chef-licensing/context.rb', line 29 def license( = {}) current_context().license end |
.license=(license) ⇒ Object
Set license context object via current context Example: ChefLicensing::Context.license = license_context_object
35 36 37 |
# File 'lib/chef-licensing/context.rb', line 35 def license=(license) current_context.license = license end |
.license_keys(options = {}) ⇒ Object
Return license keys from current context
24 25 26 |
# File 'lib/chef-licensing/context.rb', line 24 def license_keys( = {}) current_context().license_keys end |
.local_licensing_service? ⇒ Boolean
16 17 18 |
# File 'lib/chef-licensing/context.rb', line 16 def local_licensing_service? ChefLicensing::Config.is_local_license_service ||= LicensingService::Local.detected? end |
Instance Method Details
#license ⇒ Object
Get license context from local or global state
78 79 80 |
# File 'lib/chef-licensing/context.rb', line 78 def license @state.license end |
#license=(license) ⇒ Object
Set license context from local or global state
83 84 85 |
# File 'lib/chef-licensing/context.rb', line 83 def license=(license) @state.license = license end |
#license_keys ⇒ Object
The Context delegates part of its behavior to the current State object.
73 74 75 |
# File 'lib/chef-licensing/context.rb', line 73 def license_keys @state.license_keys end |
#transition_to(state) ⇒ Object
The Context allows changing the State object
65 66 67 68 69 70 |
# File 'lib/chef-licensing/context.rb', line 65 def transition_to(state) logger.debug "Chef Licensing Context: Transition to #{state.class}" @state = state @state.context = self @state. = end |