mazerte/generator-footguard

View on GitHub
app/templates/src/coffee/app/helpers/underscore_mixin.coffee

Summary

Maintainability
Test Coverage
define ['underscore'], (_) ->

  _.mixin
    isUsable: (obj) ->
      !_.isNull( obj ) and !_.isUndefined( obj ) and obj isnt ""

    usable: (obj, value) ->
      if !_.isNull( obj ) and !_.isUndefined( obj ) and obj isnt ""
        return obj
      else
        if _(value).isUsable()
          return value
        else
          return null

  return _