Skip to content

Instantly share code, notes, and snippets.

@Gazer Gazer/example1_refactor1.groovy Secret
Created Nov 23, 2016

Embed
What would you like to do?
class Exercise {
def unit() {
String unit = "min"
if (tags.contains("(floor_count)")) {
unit = "floors"
} else if (tags.contains("(step_count)")) {
unit = "steps"
}
}
}
// Fragmento original refactorizado
List <Map> exerciseEntries = []
dayEntry.exercisesEntries.each { ExerciseEntry exerciseEntry ->
Map exerciseEntryInfo = [
exercise_id: exercise.exerciseId,
value: exerciseEntry.minutes,
unit: exerciseEntry.exercise.unit()
]
exerciseEntries.add(exerciseEntryInfo)
}
resposeData.movement = exerciseEntries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.