Class: Henry::Input
- Inherits:
-
Object
- Object
- Henry::Input
- Defined in:
- lib/henry/input.rb
Overview
Henry Input
Direct Known Subclasses
Constant Summary collapse
- EXPORT_KEY =
ENV key where the Config will be exported to/imported from.
'HENRY_INPUT'
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.export!(params) ⇒ Input
Initialize and export the Input to the target ENV namespace.
-
.export_key ⇒ String
ENV key where the Config will be exported to/imported from.
-
.import! ⇒ Input
Initialize and import the Input from the target ENV namespece.
Instance Method Summary collapse
-
#export! ⇒ Input
Exports the Input to the target ENV namespace.
-
#import! ⇒ Input
Imports the Input from the target ENV namespace.
-
#initialize(params = {}) ⇒ Input
constructor
Initialize the Input with the given params or empty.
Constructor Details
#initialize(params = {}) ⇒ Input
Initialize the Input with the given params or empty.
22 23 24 |
# File 'lib/henry/input.rb', line 22 def initialize(params={}) @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/henry/input.rb', line 5 def params @params end |
Class Method Details
.export!(params) ⇒ Input
Initialize and export the Input to the target ENV namespace.
30 31 32 |
# File 'lib/henry/input.rb', line 30 def self.export!(params) self.new(params).export! end |
.export_key ⇒ String
ENV key where the Config will be exported to/imported from.
15 16 17 |
# File 'lib/henry/input.rb', line 15 def self.export_key Henry::Input::EXPORT_KEY end |
.import! ⇒ Input
Initialize and import the Input from the target ENV namespece.
45 46 47 |
# File 'lib/henry/input.rb', line 45 def self.import! self.new.import! end |
Instance Method Details
#export! ⇒ Input
Exports the Input to the target ENV namespace.
37 38 39 40 |
# File 'lib/henry/input.rb', line 37 def export! ENV[self.class.export_key] = JSON.dump(@params) self end |
#import! ⇒ Input
Imports the Input from the target ENV namespace.
52 53 54 55 56 57 58 59 60 |
# File 'lib/henry/input.rb', line 52 def import! if ENV[self.class.export_key] @params = JSON.parse(ENV[self.class.export_key]) else warn("Could not load the execution params.\nAre you running this Task via the henry-ruby-container? You should!".red) end self end |