Class: GameMachine::AppConfig

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/game_machine/app_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAppConfig



9
10
11
# File 'lib/game_machine/app_config.rb', line 9

def initialize
  @config = OpenStruct.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/game_machine/app_config.rb', line 7

def config
  @config
end

Instance Method Details

#load_config(name) ⇒ Object



34
35
36
37
38
# File 'lib/game_machine/app_config.rb', line 34

def load_config(name)
  config.name = name
  set_defaults
  load_settings(name)
end

#reloadObject



13
14
15
16
# File 'lib/game_machine/app_config.rb', line 13

def reload
  @config = OpenStruct.new
  load_config
end

#server_config(server) ⇒ Object



18
19
20
# File 'lib/game_machine/app_config.rb', line 18

def server_config(server)
  Settings.servers.send(server)
end

#set_defaultsObject



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

def set_defaults
  unless config.request_handler_routers
    config.request_handler_routers = 10
  end
  unless config.game_handler_routers
    config.game_handler_routers = 10
  end
  unless config.udp_routers
    config.udp_routers = 10
  end
end