Created
October 5, 2009 15:27
-
-
Save fmiopensource/202187 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
# add value from param to task if: | |
# - its in the list | |
# - its in the params so sending nil will nil it but sending nothing will leave it alone | |
# do some conversion on the value as well | |
{"hours" => ->(hours){hours_points_converter(hours)}, | |
"parked" => ->(parked){parked == "1" ? true : false}, | |
"description" => nil, | |
"tag_list" => nil, | |
"status_id" => ->(id){id.to_i}, | |
"position" => ->(p){p.to_i} | |
}.each{|key, value| task[key] = value.nil? ? params[key] : | |
value.call(params[key]) if params.keys.include?(key)} | |
def hours_points_converter(hours) | |
# something here | |
hours | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment