Sha256: 0f7fc80564813554345f331413739d2a177adc97a54b0c1686b953ff0a001297

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 Bytes

Contents

# Returns an object that contains only the attributes 
# that are different between obj_1 and obj_2.
# Only looks for changed attributes, not missing attributes.


# Returns a replica of the given hash.
# Don't use this method for real objects with superclasses, prototypes, and stuff.
modularity.clone_hash = (obj) ->
  result = {}
  result[key] = value for own key, value of obj
  result


modularity.object_diff = (obj_1, obj_2) ->
  result = {}
  for own key, value_2 of obj_2
    do (key, value_2) ->
      value_1 = obj_1[key]
      result[key] = value_2 if value_1 != value_2
  result


modularity.object_length = (obj) ->
  # NOTE(KG): This doesn't work in IE8.
  Object.keys(obj).length

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
modularity-rails-0.12.3 vendor/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.12.2 vendor/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.12.1 vendor/assets/javascripts/modularity/tools/object_tools.coffee