Class: KBSecret::Record::Environment
- Defined in:
- lib/kbsecret/record/environment.rb
Overview
Represents a record containing an environment variable and value.
Instance Attribute Summary collapse
-
#value ⇒ String
The value of the environment value.
-
#variable ⇒ String
The environment variable.
Attributes inherited from Abstract
#data, #label, #path, #session, #timestamp, #type
Instance Method Summary collapse
-
#load! ⇒ void
Load this record's environment variable into the environment of the current process.
- #populate_internal_fields ⇒ void
-
#to_assignment ⇒ String
A sh-style environment assignment.
-
#to_export ⇒ String
A sh-style environment export line.
Methods inherited from Abstract
data_field, data_fields, #data_fields, #defer_sync, #external_fields, external_fields, gen_methods, #initialize, #initialize_from_hash, internal?, #internal?, load!, sensitive?, #sensitive?, #sync!, #to_h, #to_s, type
Constructor Details
This class inherits a constructor from KBSecret::Record::Abstract
Instance Attribute Details
#value ⇒ String
Returns the value of the environment value.
13 |
# File 'lib/kbsecret/record/environment.rb', line 13 data_field :variable, sensitive: false |
#variable ⇒ String
Returns the environment variable.
13 |
# File 'lib/kbsecret/record/environment.rb', line 13 data_field :variable, sensitive: false |
Instance Method Details
#load! ⇒ void
This method returns an undefined value.
Load this record's environment variable into the environment of the current process.
37 38 39 |
# File 'lib/kbsecret/record/environment.rb', line 37 def load! ENV[variable] = value end |
#populate_internal_fields ⇒ void
This method returns an undefined value.
18 19 20 21 22 23 |
# File 'lib/kbsecret/record/environment.rb', line 18 def populate_internal_fields defer_sync implicit: false do self.variable = variable.shellescape self.value = value.shellescape end end |
#to_assignment ⇒ String
Returns a sh-style environment assignment.
26 27 28 |
# File 'lib/kbsecret/record/environment.rb', line 26 def to_assignment "#{variable}=#{value}" end |
#to_export ⇒ String
Returns a sh-style environment export line.
31 32 33 |
# File 'lib/kbsecret/record/environment.rb', line 31 def to_export "export #{to_assignment}" end |