Class: Mushy::GlobalVariables
- Defined in:
- lib/mushy/fluxs/global_variables.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Attributes inherited from Flux
#config, #flow, #id, #masher, #parent_fluxs, #subscribed_to, #type
Class Method Summary collapse
Instance Method Summary collapse
- #adjust_data(data) ⇒ Object
-
#initialize ⇒ GlobalVariables
constructor
A new instance of GlobalVariables.
- #process(event, config) ⇒ Object
Methods inherited from Flux
#convert_this_to_an_array, #convert_to_symbolized_hash, #execute, #execute_single_event, #group_these_results, #guard, #ignore_these_results, inherited, #join_these_results, #limit_these_results, #merge_these_results, #model_these_results, #outgoing_split_these_results, #shape_these, #sort_these_results, #standardize_these
Constructor Details
#initialize ⇒ GlobalVariables
Returns a new instance of GlobalVariables.
38 39 40 41 |
# File 'lib/mushy/fluxs/global_variables.rb', line 38 def initialize super self.state = SymbolizedHash.new end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/mushy/fluxs/global_variables.rb', line 5 def state @state end |
Class Method Details
.details ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mushy/fluxs/global_variables.rb', line 7 def self.details { name: 'GlobalVariables', title: 'Set global variables', fluxGroup: { name: 'Flows' }, description: 'Add global variables to use in any future flux. Returns what was passed to it.', config: { values: { description: 'Provide key/value pairs that will be set as global variables.', label: 'Variables', type: 'keyvalue', value: {}, }, }, examples: { "Setting Config Variables" => { description: 'Set a variable to use in any flux. Here, I can use {{api_key}} anywhere.', input: { hey: 'you' }, config: { values: { api_key: 'my api key' } }, result: { hey: 'you', } }, } } end |
Instance Method Details
#adjust_data(data) ⇒ Object
43 44 45 |
# File 'lib/mushy/fluxs/global_variables.rb', line 43 def adjust_data data state.merge data end |
#process(event, config) ⇒ Object
47 48 49 50 51 |
# File 'lib/mushy/fluxs/global_variables.rb', line 47 def process event, config values = config[:values] || SymbolizedHash.new state.merge! values event end |