Sha256: d875a2d3ab220c1575aee0310b90cddf083b90eb25f0719cfdd303ddd72d7828

Contents?: true

Size: 1.69 KB

Versions: 11

Compression:

Stored size: 1.69 KB

Contents

u = up.util

up.legacy = do ->

#  renamedProperty = (object, oldKey, newKey) ->
#    warning = -> warn('Property { %s } has been renamed to { %s } (found in %o)', oldKey, newKey, object)
#    Object.defineProperty object, oldKey,
#      get: ->
#        warning()
#        @[newKey]
#      set: (newValue) ->
#        warning()
#        @[newKey] = newValue

#  removedProperty = (object, key) ->
#    failure = -> up.fail('Deprecated: Property { %s } is no longer supported (found in %o)', key, object)
#    Object.defineProperty object, key,
#      get: failure
#      set: failure

  fixKey = (object, oldKey, newKey) ->
    if oldKey of object
      warn('Property { %s } has been renamed to { %s } (found in %o)', oldKey, newKey, object)
      u.renameKey(object, oldKey, newKey)

#  # Maps old event name to new event name
#  renamedEvents = {}
#
#  renamedEvent = (oldName, newName) ->
#    renamedEvents[oldName] = newName
#
#  fixEventName = (eventName) ->
#    if newEventName = renamedEvents[eventName]
#      warn("Event #{eventName} has been renamed to #{newEventName}")
#      newEventName
#    else
#      eventName

  renamedModule = (oldName, newName) ->
    Object.defineProperty up, oldName, get: ->
      warn("up.#{oldName} has been renamed to up.#{newName}")
      up[newName]

  warnedMessages = {}

  warn = (message, args...) ->
    message = "[DEPRECATION] #{message}"
    message = up.log.sprintf(message, args...)
    unless warnedMessages[message]
      warnedMessages[message] = true
      up.warn(message)

  renamedModule: renamedModule
#  renamedProperty: renamedProperty
#  removedProperty: removedProperty
#  renamedEvent: renamedEvent
#  fixEventName: fixEventName
  fixKey: fixKey
  warn: warn

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unpoly-rails-1.0.3 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-1.0.1 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-1.0.0 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.62.1 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.62.0 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.61.1 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.61.0 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.60.3 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.60.2 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.60.1 lib/assets/javascripts/unpoly/legacy.coffee
unpoly-rails-0.60.0 lib/assets/javascripts/unpoly/legacy.coffee