Created
February 1, 2013 00:35
-
-
Save mzikherman/4688105 to your computer and use it in GitHub Desktop.
Attempt at making a generic config for any collection
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
generateStandardCSVConfiguration: -> | |
retConfig = [] | |
for fldName, fldValue of @models[0].attributes | |
retConfig.push [ fldName, (o) -> o.get("#{fldName}") ] | |
retConfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Craig- quick question, any idea why the above is acting weird? I was thinking we could put a method like this on a collection, so getting that collection to CSV would be like:
My intention was to basically loop over all the attributes on the model and do this mapping for the CSV library. The issue is the (o) -> o.get("#{fldName}") seems to not be doing the string evaluation, so the config winds up looking like:
whereas I wanted that string to be evaluated, so it should be:
and so on. Am I doing something bizarre?