Class: TestTrack::ConfigUpdater

Inherits:
Object
  • Object
show all
Defined in:
app/models/test_track/config_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema_file_path = Rails.root.join('db/test_track_schema.yml')) ⇒ ConfigUpdater

Returns a new instance of ConfigUpdater.



2
3
4
# File 'app/models/test_track/config_updater.rb', line 2

def initialize(schema_file_path = Rails.root.join('db/test_track_schema.yml'))
  @schema_file_path = schema_file_path
end

Instance Method Details

#drop_split(name) ⇒ Object Also known as: finish_split



16
17
18
19
20
21
22
# File 'app/models/test_track/config_updater.rb', line 16

def drop_split(name)
  TestTrack::Remote::SplitConfig.destroy_existing(name)

  splits.except!(name.to_s)

  persist_schema!
end

#identifier_type(name) ⇒ Object



25
26
27
28
29
30
31
# File 'app/models/test_track/config_updater.rb', line 25

def identifier_type(name)
  create_identifier_type(name)

  identifier_types << name.to_s

  persist_schema!
end

#load_schemaObject



33
34
35
36
37
38
39
40
41
# File 'app/models/test_track/config_updater.rb', line 33

def load_schema
  identifier_types.each do |name|
    create_identifier_type(name)
  end

  splits.each do |name, weighting_registry|
    create_split(name, weighting_registry)
  end
end

#split(name, weighting_registry) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/models/test_track/config_updater.rb', line 6

def split(name, weighting_registry)
  create_split(name, weighting_registry)

  name = name.to_s
  splits.except!(*unpersisted_split_names)
  splits[name] = weighting_registry.stringify_keys

  persist_schema!
end