lib/routes.js.coffee in js-routes-1.2.9 vs lib/routes.js.coffee in js-routes-1.3.0
- old
+ new
@@ -10,10 +10,11 @@
defaults =
prefix: "PREFIX"
default_url_options: DEFAULT_URL_OPTIONS
NodeTypes = NODE_TYPES
+SpecialOptionsKey = "SPECIAL_OPTIONS_KEY"
ReservedOptions = [
'anchor'
'trailing_slash'
'host'
@@ -62,16 +63,17 @@
path.join "://"
extract_options: (number_of_params, args) ->
last_el = args[args.length - 1]
if (args.length > number_of_params and last_el == undefined) or(last_el? and "object" is @get_object_type(last_el) and !@looks_like_serialized_model(last_el))
- args.pop() || {}
+ options = args.pop() || {}
+ delete options[SpecialOptionsKey]
+ options
else
{}
looks_like_serialized_model: (object) ->
- # consider object a model if it have a path identifier properties like id and to_param
- "id" of object or "to_param" of object
+ !object[SpecialOptionsKey] and ("id" of object or "to_param" of object)
path_identifier: (object) ->
return "0" if object is 0
# null, undefined, false or ''