Code cleanup.
This commit is contained in:
parent
e7ca5cbbaf
commit
b1a90e03ba
1 changed files with 9 additions and 9 deletions
|
@ -4,33 +4,33 @@ class App.Config
|
||||||
@init: ->
|
@init: ->
|
||||||
_instance ?= new _configSingleton
|
_instance ?= new _configSingleton
|
||||||
|
|
||||||
@get: ( key, group ) ->
|
@get: (key, group) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _configSingleton
|
_instance ?= new _configSingleton
|
||||||
_instance.get( key, group )
|
_instance.get(key, group)
|
||||||
|
|
||||||
@set: ( key, value, group ) ->
|
@set: (key, value, group) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _configSingleton
|
_instance ?= new _configSingleton
|
||||||
_instance.set( key, value, group )
|
_instance.set(key, value, group)
|
||||||
|
|
||||||
@_all: ->
|
@all: ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _configSingleton
|
_instance ?= new _configSingleton
|
||||||
_instance._all()
|
_instance.all()
|
||||||
|
|
||||||
class _configSingleton
|
class _configSingleton
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@config = {}
|
@config = {}
|
||||||
|
|
||||||
get: ( key, group ) ->
|
get: (key, group) ->
|
||||||
if group
|
if group
|
||||||
return undefined if !group of @config
|
return undefined if !group of @config
|
||||||
return undefined if @config[group] is undefined
|
return undefined if @config[group] is undefined
|
||||||
return @config[group][key]
|
return @config[group][key]
|
||||||
return @config[key]
|
return @config[key]
|
||||||
|
|
||||||
set: ( key, value, group ) ->
|
set: (key, value, group) ->
|
||||||
if group
|
if group
|
||||||
if !@config[group]
|
if !@config[group]
|
||||||
@config[group] = {}
|
@config[group] = {}
|
||||||
|
@ -38,5 +38,5 @@ class _configSingleton
|
||||||
else
|
else
|
||||||
@config[key] = value
|
@config[key] = value
|
||||||
|
|
||||||
_all: ->
|
all: ->
|
||||||
@config
|
@config
|
||||||
|
|
Loading…
Reference in a new issue