Sha256: 1dd1d1dd3dfaed7e91453b084dde774499317e78995841b49df7fb8f4e8a3c35
Contents?: true
Size: 1.46 KB
Versions: 36
Compression:
Stored size: 1.46 KB
Contents
module Henry # Henry Input class Input attr_reader :params # ENV key where the Config will be exported to/imported from. # # @return [String] the env config key. EXPORT_KEY = 'HENRY_INPUT' # ENV key where the Config will be exported to/imported from. # # @return [String] the env config key. def self.export_key Henry::Input::EXPORT_KEY end # Initialize the Input with the given params or empty. # # @param params [Hash] the Input params. def initialize(params={}) @params = params end # Initialize and export the Input to the target ENV namespace. # # @param params [Hash] the Input params to be exported. # @return [Input] def self.export!(params) self.new(params).export! end # Exports the Input to the target ENV namespace. # # @return [Input] def export! ENV[self.class.export_key] = JSON.dump(@params) self end # Initialize and import the Input from the target ENV namespece. # # @return [Input] def self.import! self.new.import! end # Imports the Input from the target ENV namespace. # # @return [Input] 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 end end
Version data entries
36 entries across 36 versions & 1 rubygems