Class: KBSecret::Record::Environment
- Defined in:
- lib/kbsecret/record/environment.rb
Overview
Represents a record containing an environment variable and value.
Instance Attribute Summary
Attributes inherited from Abstract
#data, #label, #path, #session, #timestamp, #type
Instance Method Summary collapse
-
#initialize(session, label, variable, value) ⇒ Environment
constructor
A new instance of Environment.
-
#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, gen_methods, #initialize_from_hash, load!, #sync!, #to_h, #to_s, type
Constructor Details
#initialize(session, label, variable, value) ⇒ Environment
Returns a new instance of Environment.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kbsecret/record/environment.rb', line 16 def initialize(session, label, variable, value) super(session, label) @data = { environment: { variable: variable.shellescape, value: value.shellescape, }, } end |
Instance Method Details
#to_assignment ⇒ String
Returns a sh-style environment assignment.
28 29 30 |
# File 'lib/kbsecret/record/environment.rb', line 28 def to_assignment "#{variable}=#{value}" end |
#to_export ⇒ String
Returns a sh-style environment export line.
33 34 35 |
# File 'lib/kbsecret/record/environment.rb', line 33 def to_export "export #{to_assignment}" end |