Module: Trailblazer::Activity::State::Config
- Defined in:
- lib/trailblazer/activity/config.rb
Overview
Compile-time
DISCUSS: we could replace parts with Hamster::Hash.
Class Method Summary collapse
Class Method Details
.get(state, *args) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/trailblazer/activity/config.rb', line 26 def get(state, *args) directive, key = *args return state[directive] if args.size == 1 return state[directive][key] if state.key?(directive) nil end |
.set(state, *args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/trailblazer/activity/config.rb', line 9 def set(state, *args) if args.size == 2 key, value = *args state = state.merge(key => value) else directive, key, value = *args state = state.merge( directive => {}.freeze ) unless state.key?(directive) directive_hash = state[directive].merge(key => value) state = state.merge( directive => directive_hash.freeze ) end state end |