Class: SpecStore
- Inherits:
-
Object
- Object
- SpecStore
- Defined in:
- lib/spec_store.rb
Instance Method Summary collapse
- #get_config(config_name) ⇒ Object
- #get_gate(gate_name) ⇒ Object
- #get_id_list(list_name) ⇒ Object
- #has_config?(config_name) ⇒ Boolean
- #has_gate?(gate_name) ⇒ Boolean
-
#initialize(network, error_callback = nil, config_sync_interval = 10, id_lists_sync_interval = 60) ⇒ SpecStore
constructor
A new instance of SpecStore.
- #shutdown ⇒ Object
Constructor Details
#initialize(network, error_callback = nil, config_sync_interval = 10, id_lists_sync_interval = 60) ⇒ SpecStore
Returns a new instance of SpecStore.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spec_store.rb', line 5 def initialize(network, error_callback = nil, config_sync_interval = 10, id_lists_sync_interval = 60) @network = network @last_sync_time = 0 @config_sync_interval = config_sync_interval @id_lists_sync_interval = id_lists_sync_interval @store = { :gates => {}, :configs => {}, :id_lists => {}, } e = download_config_specs error_callback.call(e) unless error_callback.nil? download_id_lists @config_sync_thread = sync_config_specs @id_lists_sync_thread = sync_id_lists end |
Instance Method Details
#get_config(config_name) ⇒ Object
41 42 43 44 |
# File 'lib/spec_store.rb', line 41 def get_config(config_name) return nil unless has_config?(config_name) @store[:configs][config_name] end |
#get_gate(gate_name) ⇒ Object
36 37 38 39 |
# File 'lib/spec_store.rb', line 36 def get_gate(gate_name) return nil unless has_gate?(gate_name) @store[:gates][gate_name] end |
#get_id_list(list_name) ⇒ Object
46 47 48 |
# File 'lib/spec_store.rb', line 46 def get_id_list(list_name) @store[:id_lists][list_name] end |
#has_config?(config_name) ⇒ Boolean
32 33 34 |
# File 'lib/spec_store.rb', line 32 def has_config?(config_name) @store[:configs].key?(config_name) end |
#has_gate?(gate_name) ⇒ Boolean
28 29 30 |
# File 'lib/spec_store.rb', line 28 def has_gate?(gate_name) @store[:gates].key?(gate_name) end |
#shutdown ⇒ Object
23 24 25 26 |
# File 'lib/spec_store.rb', line 23 def shutdown @config_sync_thread&.exit @id_lists_sync_thread&.exit end |