Sha256: 339600ea9016bfb0f821ab7d90725a5a8101b6703868a4af5e2d06e5c28e7c2f

Contents?: true

Size: 748 Bytes

Versions: 14

Compression:

Stored size: 748 Bytes

Contents

# 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


# 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.
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


# Returns the number of attributes of the given object.
# NOTE(KG): This doesn't work in IE8.
modularity.object_length = (obj) ->
  Object.keys(obj).length

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
modularity-rails-0.23.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.22.1 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.22.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.21.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.20.3 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.20.2 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.20.1 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.20.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.19.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.17.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.16.0 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-coffee-rails-0.0.1 app/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.15.0 vendor/assets/javascripts/modularity/tools/object_tools.coffee
modularity-rails-0.14.0 vendor/assets/javascripts/modularity/tools/object_tools.coffee