/**
 * Computes the final instance state after hook is executed.
 *
 * @param {Object} ctx The hook context
 * @return {Object} The final instance state
 */
exports.getFinalState = function(ctx) {
    if (ctx.isNewInstance)
        return ctx.instance;
    if (ctx.currentInstance) {
        return Object.assign({},
            ctx.currentInstance.__data,
            ctx.data || ctx.instance
        );
    }

    return null;
};

/**
 * Determines if hook is affecting multiple instances.
 *
 * @param {Object} ctx The hook context
 * @return {Boolean} %true for multiple instances, %false otherwhise
 */
exports.isMultiple = function(ctx) {
    return !ctx.isNewInstance && !ctx.currentInstance;
};