Last active
August 29, 2015 14:01
-
-
Save GLips/3993ae5cf043d9ebf34c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LW.GithubSource = LW.Model.extend | |
# Example: [master, develop] | |
branches: DS.attr('array') | |
# Returns a list that looks like "master, and develop" | |
# If setting, just takes a comma separated list "master, develop" and turns it into [master, develop] | |
comma_branches: ((key, value)-> | |
arguments[0] = 'branches' | |
@comma_separated.apply @, arguments | |
).property('branches') | |
LW.Model = DS.Model.extend | |
comma_separated: (property, value)-> | |
if arguments.length > 1 | |
# Filter out blank values created from splitting a list like "master,,,,,,develop" | |
@set property, value.split(',').filter (x) -> not Em.isBlank(x) | |
if @get property | |
arr = @get(property).filter (x) -> not Em.isBlank(x) | |
last = arr.length - 1 | |
arr[last] = 'and ' + arr[last] if arr.length > 1 | |
arr.join(', ') | |
# This datatype is very straightforward. | |
LW.ArrayTransform = DS.Transform.extend | |
deserialize: (data)-> | |
return data if data instanceof Array | |
null | |
serialize: (data)-> | |
return data if data instanceof Array | |
null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment