Class: DK::ConfigAdapter

Inherits:
Adapter show all
Defined in:
lib/draftking/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, file = nil) ⇒ ConfigAdapter

Returns a new instance of ConfigAdapter.



16
17
18
19
# File 'lib/draftking/config.rb', line 16

def initialize(data, file = nil)
  super(data)
  @file = file
end

Instance Method Details

#adaptObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/draftking/config.rb', line 21

def adapt
  if @data.keys.include?('consumer_key')
    r = OpenStruct.new
    r.user_commands = []
    r.api_keys = @data
    puts "Config #{@file} needs to be updated!"
    print 'Enter a name for this configuration: '
    r.config_name = DK::Config.get_input
    Config.save_file(config: r, filename: @file)
  end
  r || @data
end