Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename @urls => @links to correspond with HAL spec

This also makes it more clear these are links to _other_ resources as
suppose to alternate urls for the object.
  • Loading branch information...
commit ec2e02eb941cabc6855d2ded8ccb09455c705c1b 1 parent 66358b3
@bruth bruth authored
View
14 coffee/cilantro/models/base.coffee
@@ -4,16 +4,17 @@ define [
class Model extends c.Backbone.Model
url: ->
- if @isNew() then super else @urls.self
+ if @isNew() then super else @links.self
constructor: (attrs, options) ->
- @urls = {}
+ @links = {}
super(attrs, options)
parse: (attrs, options) ->
if attrs? and attrs._links?
+ @links = {}
for name, link of attrs._links
- @urls[name] = link.href
+ @links[name] = link.href
delete attrs._links
return attrs
@@ -22,16 +23,17 @@ define [
model: Model
url: ->
- if @isNew() then super else @urls.self
+ if @isNew() then super else @links.self
constructor: (attrs, options) ->
- @urls = {}
+ @links = {}
super(attrs, options)
parse: (attrs, options) ->
if attrs? and attrs._links?
+ @links = {}
for name, link of attrs._links
- @urls[name] = link.href
+ @links[name] = link.href
delete attrs._links
return attrs
View
2  coffee/cilantro/models/concept.coffee
@@ -24,7 +24,7 @@ define [
if resp?
# Set the endpoint for related fields
- @fields.url = => @urls.fields
+ @fields.url = => @links.fields
if resp.fields?
@fields.set(resp.fields, options)
View
12 coffee/cilantro/models/field.coffee
@@ -10,12 +10,12 @@ define [
@_cache = {}
distribution: (handler, cache=true) ->
- if not @urls.distribution? then handler()
+ if not @links.distribution? then handler()
if cache and @_cache.distribution?
handler(@_cache.distribution)
else
c.Backbone.ajax
- url: @urls.distribution
+ url: @links.distribution
dataType: 'json'
success: (resp) =>
@_cache.distribution = if cache then resp else null
@@ -23,12 +23,12 @@ define [
return
stats: (handler, cache=true) ->
- if not @urls.stats? then handler()
+ if not @links.stats? then handler()
if cache and @_cache.stats?
handler(@_cache.stats)
else
c.Backbone.ajax
- url: @urls.stats
+ url: @links.stats
dataType: 'json'
success: (resp) =>
@_cache.stats = if cache then resp else null
@@ -36,12 +36,12 @@ define [
return
values: (handler, cache=true) ->
- if not @urls.values? then handler()
+ if not @links.values? then handler()
if cache and @_cache.values?
handler(@_cache.values)
else
c.Backbone.ajax
- url: @urls.values
+ url: @links.values
dataType: 'json'
success: (resp) =>
@_cache.values = if cache then resp else null
Please sign in to comment.
Something went wrong with that request. Please try again.