Simplify method names on DeserializerManager

This commit is contained in:
Kevin Sawicki 2013-10-02 15:30:08 -07:00
parent ca137974c9
commit 08177feb67
2 changed files with 15 additions and 9 deletions

View File

@ -1,20 +1,25 @@
{Document} = require 'telepath' {Document} = require 'telepath'
# Public: Manages the deserializers used for serialized state
module.exports = module.exports =
class DeserializerManager class DeserializerManager
constructor: -> constructor: ->
@deserializers = {} @deserializers = {}
@deferredDeserializers = {} @deferredDeserializers = {}
registerDeserializer: (klasses...) -> # Public: Add a deserializer.
add: (klasses...) ->
@deserializers[klass.name] = klass for klass in klasses @deserializers[klass.name] = klass for klass in klasses
registerDeferredDeserializer: (name, fn) -> # Public: Add a deferred deserializer.
addDeferred: (name, fn) ->
@deferredDeserializers[name] = fn @deferredDeserializers[name] = fn
unregisterDeserializer: (klasses...) -> # Public: Remove a deserializer.
remove: (klasses...) ->
delete @deserializers[klass.name] for klass in klasses delete @deserializers[klass.name] for klass in klasses
# Public: Deserialize the state and params.
deserialize: (state, params) -> deserialize: (state, params) ->
return unless state? return unless state?
@ -27,7 +32,8 @@ class DeserializerManager
else else
console.warn "No deserializer found for", state console.warn "No deserializer found for", state
getDeserializer: (state) -> # Public: Get the deserializer for the state.
get: (state) ->
return unless state? return unless state?
name = state.get?('deserializer') ? state.deserializer name = state.get?('deserializer') ? state.deserializer

View File

@ -104,17 +104,17 @@ window.onerror = ->
atom.openDevTools() atom.openDevTools()
window.registerDeserializers = (args...) -> window.registerDeserializers = (args...) ->
atom.deserializers.registerDeserializer(args...) atom.deserializers.add(args...)
window.registerDeserializer = (args...) -> window.registerDeserializer = (args...) ->
atom.deserializers.registerDeserializer(args...) atom.deserializers.add(args...)
window.registerDeferredDeserializer = (args...) -> window.registerDeferredDeserializer = (args...) ->
atom.deserializers.registerDeferredDeserializer(args...) atom.deserializers.addDeferred(args...)
window.unregisterDeserializer = (args...) -> window.unregisterDeserializer = (args...) ->
atom.deserializers.unregisterDeserializer(args...) atom.deserializers.remove(args...)
window.deserialize = (args...) -> window.deserialize = (args...) ->
atom.deserializers.deserialize(args...) atom.deserializers.deserialize(args...)
window.getDeserializer = (args...) -> window.getDeserializer = (args...) ->
atom.deserializer.getDeserializer(args...) atom.deserializers.get(args...)
window.requireWithGlobals = (args...) -> window.requireWithGlobals = (args...) ->
atom.requireWithGlobals(args...) atom.requireWithGlobals(args...)