class SpecStore
Public Class Methods
new(specs_json)
click to toggle source
# File lib/spec_store.rb, line 5 def initialize(specs_json) @last_sync_time = 0 @store = { :gates => {}, :configs => {}, } process(specs_json) end
Public Instance Methods
get_config(config_name)
click to toggle source
# File lib/spec_store.rb, line 46 def get_config(config_name) return nil unless has_config?(config_name) @store[:configs][config_name] end
get_gate(gate_name)
click to toggle source
# File lib/spec_store.rb, line 41 def get_gate(gate_name) return nil unless has_gate?(gate_name) @store[:gates][gate_name] end
has_config?(config_name)
click to toggle source
# File lib/spec_store.rb, line 37 def has_config?(config_name) return @store[:configs].key?(config_name) end
has_gate?(gate_name)
click to toggle source
# File lib/spec_store.rb, line 33 def has_gate?(gate_name) return @store[:gates].key?(gate_name) end
process(specs_json)
click to toggle source
# File lib/spec_store.rb, line 14 def process(specs_json) if specs_json.nil? return end @last_sync_time = specs_json['time'] || @last_sync_time return unless specs_json['has_updates'] == true && !specs_json['feature_gates'].nil? && !specs_json['dynamic_configs'].nil? @store = { :gates => {}, :configs => {}, } specs_json['feature_gates'].map{|gate| @store[:gates][gate['name']] = gate } specs_json['dynamic_configs'].map{|config| @store[:configs][config['name']] = config } end