<commit_before>autobahn = require "autobahn"
Backbone = require "backbone"
[WAMP_Model, WAMP_Collection] = require "./backbone.wamp.coffee"

global.WAMP_CONNECTION = new autobahn.Connection
    url   : "ws://127.0.0.1:8080/ws"
    realm : "realm1"

global.WAMP_CONNECTION.onopen = ->
    class Collection extends WAMP_Collection

        wamp_my_id : "nodejs"
        
        url : "test_collection"

        wamp_read : (options, autobahn)->
            {data, extra} = options

            if extra.wamp_model_id
                {id: 1, name: "John", age: 25}
            else if extra.wamp_model_id is null
                {id: 1, name: "John", age: 20}
            else
                [{a: 1, b: 2}, {c: 1, d: 2}]

            console.log arguments
            [{a: 1, b: 2}, {c: 1, d: 2}]




    c = new Collection()


global.WAMP_CONNECTION.open()<commit_msg>ensured Collection and attached Model works properly<commit_after>autobahn = require "autobahn"
_ = require "underscore"
Backbone = require "backbone"
[WAMP_Model, WAMP_Collection] = require "./backbone.wamp.coffee"

global.WAMP_CONNECTION = new autobahn.Connection
    url   : "ws://127.0.0.1:8080/ws"
    realm : "realm1"

global.WAMP_CONNECTION.onopen = ->
    class Collection extends WAMP_Collection

        wamp_my_id : "nodejs"
        
        url : "test_collection"

        wamp_read : (options)->
            {extra} = options

            if extra.wamp_model_id
                @get extra.wamp_model_id
                .toJSON()
            else
                @toJSON()

        wamp_create : (options)->
            {data} = options

            @add _.extend(data, id : parseInt _.uniqueId())
            @last().toJSON()

        wamp_update : (options)->
            {data, extra} = options

            @get extra.wamp_model_id
            .set data

        wamp_patch : (options)->
            {data, extra} = options

            @get extra.wamp_model_id
            .set data

        wamp_delete : (options)->
            {extra} = options

            @remove @get extra.wamp_model_id
            {}


    c = new Collection()


global.WAMP_CONNECTION.open()
{'fraction_non_alphanumeric': 0.1137947050627032, 'fraction_numerical': 0.01672085462145843, 'mean_word_length': 1.8342105263157895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6758954', 'n_tokens_mistral': 727, 'n_tokens_neox': 673, 'n_words': 157}