Sha256: 9b39ebc43e9bebc45971e4b814a24f0d117f7681f3b882da0934042a5eba2b45

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

class $paramSerializer extends AngularServiceModel
  @register(MaterialRaingular.app)
  @inject('$httpParamSerializer')
  clean: (obj) -> @$httpParamSerializer @update(obj)
  update: (obj) ->
    res = {}
    for key,val of @strip(obj)
      continue if val == obj['$' + key + '_was']
      continue if val?.toString() == obj['$' + key + '_was']?.toString()
      continue if [undefined,null].includes(val) && [undefined,null].includes(obj["$#{key}_was"])
      continue if ActiveRecord.$Collection.isCollection(val)
      res[key] = val
    res
  strip: (obj) ->
    res = {}
    for key,val of obj
      continue if ['$','_'].includes(key[0]) || key in ['constructor','initialize']
      continue if ActiveRecord.$Collection.isCollection(val)
      res[key] = if (typeof val == 'object' && val != null && !val instanceof Date) then @strip(val) else val
    res
  create: (obj) ->
    res = {}
    for key,val of @strip(obj)
      continue if typeof val == 'undefined'
      res[key] = val
    res

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
material_raingular-0.6.16 lib/assets/javascripts/active_record/param_serializer.coffee
material_raingular-0.6.15 lib/assets/javascripts/active_record/param_serializer.coffee
material_raingular-0.6.14 lib/assets/javascripts/active_record/param_serializer.coffee