Sha256: eb61d1fa4317a5c5c2dc72fc3fd7b11814cd9a915e79bacb710f6577319222c6

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# -----------------------------------------------------------------------------
# Author: Alexander Kravets <alex@slatestudio.com>,
#         Slate Studio (http://www.slatestudio.com)
#
# Coding Guide:
#   https://github.com/thoughtbot/guides/tree/master/style/coffeescript
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# MONGOSTEEN (RAILS) OBJECT STORE IMPLEMENTATION
# -----------------------------------------------------------------------------
class @MongosteenObjectStore extends RestObjectStore

  # PRIVATE ===============================================

  _initialize_database: ->
    @dataFetchLock = false
    @ajaxConfig =
      processData: false
      contentType: false


  # generate rest url for resource
  _resource_url: -> "#{ @config.path }.json"


  # get form data object from serialized form object,
  # it uses special format for object names for support of:
  # files, lists, nested objects
  _parse_form_object: (serializedFormObject) ->
    formDataObject = new FormData()

    for attr_name, attr_value of serializedFormObject

      # special case for LIST inputs, values separated with comma
      if attr_name.indexOf('[__LIST__') > -1
        attr_name = attr_name.replace('__LIST__', '')
        values    = attr_value.split(',')

        for value in values
          formDataObject.append("#{ @config.resource }#{ attr_name }[]", value)

      else
        # special case for FILE inputs
        if attr_name.startsWith('__FILE__')
          attr_name = attr_name.replace('__FILE__', '')

        formDataObject.append("#{ @config.resource }#{ attr_name }", attr_value)

    return formDataObject




Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chr-0.2.7 app/assets/javascripts/chr/store/mongosteen-object-store.coffee