Class: Henry::Input
- Inherits:
-
Object
- Object
- Henry::Input
- Defined in:
- lib/henry/input.rb
Overview
Henry Input
Constant Summary collapse
- EXPORT_KEY =
ENV key where the Input 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.
-
.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.
13 14 15 |
# File 'lib/henry/input.rb', line 13 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.
21 22 23 |
# File 'lib/henry/input.rb', line 21 def self.export!(params) self.new(params).export! end |
.import! ⇒ Input
Initialize and import the Input from the target ENV namespece.
36 37 38 |
# File 'lib/henry/input.rb', line 36 def self.import! self.new.import! end |
Instance Method Details
#export! ⇒ Input
Exports the Input to the target ENV namespace.
28 29 30 31 |
# File 'lib/henry/input.rb', line 28 def export! ENV[EXPORT_KEY] = JSON.dump(@params) self end |
#import! ⇒ Input
Imports the Input from the target ENV namespace.
43 44 45 46 47 48 49 50 51 |
# File 'lib/henry/input.rb', line 43 def import! if ENV[EXPORT_KEY] @params = JSON.parse(ENV[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 |