'Handles a Decision according to SWF docs.
See: http://docs.aws.amazon.com/amazonswf/latest/apireference/API_Decision.html'

def handle_decisions(self, event_id, decisions):

    for decision in decisions:
        decision_type = decision[u'decisionType']
        attributes_key = u'{0}DecisionAttributes'.format(decapitalize(decision_type))
        attributes = decision.get(attributes_key, {})
        if (decision_type == u'CompleteWorkflowExecution'):
            self.complete(event_id, attributes.get(u'result'))
        elif (decision_type == u'FailWorkflowExecution'):
            self.fail(event_id, attributes.get(u'details'), attributes.get(u'reason'))
        elif (decision_type == u'ScheduleActivityTask'):
            self.schedule_activity_task(event_id, attributes)
        else:
            raise NotImplementedError(u'Cannot    handle    decision:    {0}'.format(decision_type))
    self.open_counts[u'openDecisionTasks'] -= 1
