Sha256: 087a6e9fcdf2cdef216c74f3d6660e52f448f8de16b8b695bd6ef4c41d087bff

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

moduleKeywords = ['extended', 'included']

@Gmaps4Rails = {}

class @Gmaps4Rails.Common

  @extend: (obj) ->
    for key, value of obj when key not in moduleKeywords
      @[key] = value

    obj.extended?.apply(@)
    this

  @include: (obj) ->
    for key, value of obj when key not in moduleKeywords
      # Assign properties to the prototype
      @::[key] = value
    obj.included?.apply(@)
    this

  #//basic function to check existence of a variable
  exists : (var_name) ->
    return (var_name  != "" and typeof var_name != "undefined")

  mergeObjects: (object, defaultObject) ->
    @constructor.mergeObjects(object, defaultObject)

  @mergeObjects: (object, defaultObject) ->
    copy_object = {}
    for key, value of object
      copy_object[key] = value

    for key, value of defaultObject
        copy_object[key] = value unless copy_object[key]?
    return copy_object

  @mergeWith : (object) ->
    for key, value of object
        @[key] = value unless @[key]?

  #gives a value between -1 and 1
  random : -> return(Math.random() * 2 -1)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gmaps4rails-2.0.0.pre vendor/assets/javascripts/gmaps4rails/base/common.coffee