lib/routes.js.coffee in js-routes-1.4.12 vs lib/routes.js.coffee in js-routes-1.4.13
- old
+ new
@@ -1,10 +1,9 @@
###
File generated by js-routes GEM_VERSION
Based on Rails RAILS_VERSION routes of APP_CLASS
###
-root = (exports ? this)
ParameterMissing = (message, fileName, lineNumber) ->
instance = new Error(message, fileName, lineNumber)
if Object.setPrototypeOf
Object.setPrototypeOf instance, Object.getPrototypeOf(this)
@@ -361,11 +360,11 @@
@_classToTypeCache = {}
for name in "Boolean Number String Function Array Date RegExp Object Error".split(" ")
@_classToTypeCache["[object #{name}]"] = name.toLowerCase()
@_classToTypeCache
get_object_type: (obj) ->
- return root.jQuery.type(obj) if root.jQuery and root.jQuery.type?
+ return this.jQuery.type(obj) if this.jQuery and this.jQuery.type?
return "#{obj}" unless obj?
(if typeof obj is "object" or typeof obj is "function" then @_classToType()[Object::toString.call(obj)] or "object" else typeof obj)
# indexOf helper
indexOf: (array, element) -> if Array::indexOf then array.indexOf(element) else @indexOfImplementation(array, element)
@@ -393,15 +392,21 @@
routes = ROUTES
routes.configure = (config) -> Utils.configure(config)
routes.config = -> Utils.config()
routes.default_serializer = (object, prefix) ->
Utils.default_serializer(object, prefix)
- # Browser globals
- Utils.namespace(root, NAMESPACE, routes)
Object.assign({default: routes}, routes)
result = Utils.make()
+
# Set up Routes appropriately for the environment.
if typeof define is "function" and define.amd
# AMD
define [], -> result
+else if module?
+ # CommonJS
+ module.exports = result
+else
+ # Browser globals
+ Utils.namespace(this, NAMESPACE, result)
+
return result