This repository was archived by the owner on Oct 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtest_chat_service.js
More file actions
50 lines (40 loc) · 2.77 KB
/
test_chat_service.js
File metadata and controls
50 lines (40 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Generated by Opal 0.9.4 */
(function(Opal) {
Opal.dynamic_require_severity = "error";
var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
function $rb_minus(lhs, rhs) {
return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
}
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2;
Opal.add_stubs(['$now', '$to_i', '$-', '$days', '$hour', '$minutes', '$call', '$<<']);
return (function($base, $super) {
function $ChatService(){};
var self = $ChatService = $klass($base, $super, 'ChatService', $ChatService);
var def = self.$$proto, $scope = self.$$scope, TMP_1;
def.block = def.messages = def.user_name = nil;
Opal.defn(self, '$initialize', TMP_1 = function() {
var self = this, $iter = TMP_1.$$p, block = $iter || nil, time = nil;
TMP_1.$$p = null;
self.block = block;
time = $scope.get('Time').$now();
return self.messages = [$hash2(["from", "time", "message"], {"from": "user1", "time": ($rb_minus(time, (10).$days())).$to_i(), "message": "A 2 point message: \n+ point 1\n+ point 2\nGot it?"}), $hash2(["from", "time", "message"], {"from": "user2", "time": ($rb_minus(time, (8).$days())).$to_i(), "message": "message sent 8 days ago, by user 2"}), $hash2(["from", "time", "message"], {"from": "user3", "time": ($rb_minus(time, (5).$days())).$to_i(), "message": "message sent in the last week"}), $hash2(["from", "time", "message"], {"from": "user2", "time": ($rb_minus(time, (4).$days())).$to_i(), "message": "message sent **also** in the last week"}), $hash2(["from", "time", "message"], {"from": "user1", "time": ($rb_minus(time, (1).$hour())).$to_i(), "message": "Was sent within the last hour!"}), $hash2(["from", "time", "message"], {"from": "user2", "time": ($rb_minus(time, (30).$minutes())).$to_i(), "message": "Was sent 30 minutes ago"}), $hash2(["from", "time", "message"], {"from": "user3", "time": ($rb_minus(time, (10).$minutes())).$to_i(), "message": "Was just sent\n\n\n\n\n\n\n\n\nwith a lot of blanks"}), $hash2(["from", "time", "message"], {"from": "user1", "time": $scope.get('Time').$now().$to_i(), "message": "just now"})];
});
Opal.defn(self, '$login', function(user_name) {
var self = this;
self.user_name = user_name;
return self.block.$call(self.messages);
});
Opal.defn(self, '$id', function() {
var self = this;
return self.user_name;
});
return (Opal.defn(self, '$send', function(data) {
var self = this;
if (data == null) {
data = $hash2([], {})
}
self.messages['$<<'](data);
return self.block.$call([data]);
}), nil) && 'send';
})($scope.base, null)
})(Opal);