Class: ConsulStockpile::LoadJsonKV
- Defined in:
- lib/consul_stockpile/load_json_kv.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
Returns the value of attribute json.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(json:) ⇒ LoadJsonKV
constructor
A new instance of LoadJsonKV.
Methods inherited from Base
Constructor Details
#initialize(json:) ⇒ LoadJsonKV
Returns a new instance of LoadJsonKV.
8 9 10 |
# File 'lib/consul_stockpile/load_json_kv.rb', line 8 def initialize(json:) self.json = json end |
Instance Attribute Details
#json ⇒ Object
Returns the value of attribute json.
6 7 8 |
# File 'lib/consul_stockpile/load_json_kv.rb', line 6 def json @json end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/consul_stockpile/load_json_kv.rb', line 12 def call Logger.info 'Loading json backup into consul kv store' return if json.nil? ary = JSON.parse(json) return if ary.empty? ary.each do |item| Diplomat::Kv.put(item['key'], item['value']) end end |