nark 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nark/version.rb +1 -1
- data/lib/nark.rb +6 -3
- data/spec/nark_spec.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d5b980ef324ae850b4a96e57c7f55bd4a61539
|
4
|
+
data.tar.gz: eaea905439f9e4445d7b124e04701bc7cec6f575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9dafea998ef3affcfd00a5427d99ca256bd82e4892b60a7295e4cc024633ee162bb1fe8d36876a500fde79e83a37f37ff6f9ceeff982296d026410cd40968ad
|
7
|
+
data.tar.gz: 22a853b9b32d680fa05c891366f38d6b798c0a787a5a4be90966d294ca293df4779ccba03fa126a2b64b0175e55fb1a29fe6c0f133a88430347777a15dee9f8c
|
data/lib/nark/version.rb
CHANGED
data/lib/nark.rb
CHANGED
@@ -6,12 +6,15 @@ module Nark
|
|
6
6
|
klass.extend ClassMethods
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def serializable_hash(value = nil)
|
10
|
+
@serializable_hash = value if value
|
11
|
+
@serializable_hash
|
12
|
+
end
|
10
13
|
|
11
14
|
def emit(timestamp: nil)
|
12
|
-
hash = serializable_hash
|
15
|
+
hash = serializable_hash.clone
|
13
16
|
hash.merge! keen: { timestamp: timestamp } if timestamp
|
14
|
-
Keen.publish self.class.collection_name,
|
17
|
+
Keen.publish self.class.collection_name, hash
|
15
18
|
self
|
16
19
|
end
|
17
20
|
|
data/spec/nark_spec.rb
CHANGED
@@ -6,7 +6,7 @@ class TestSignup
|
|
6
6
|
collection_name :test_signups
|
7
7
|
|
8
8
|
def initialize(attributes)
|
9
|
-
|
9
|
+
serializable_hash attributes
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -26,6 +26,13 @@ describe TestSignup do
|
|
26
26
|
TestSignup.new(user_name: 'everydayhero').emit timestamp: time
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'should not mutate serializable_hash' do
|
30
|
+
allow(Keen).to receive :publish
|
31
|
+
signup = TestSignup.new({})
|
32
|
+
signup.emit timestamp: Time.now
|
33
|
+
expect(signup.serializable_hash).to eq({})
|
34
|
+
end
|
35
|
+
|
29
36
|
it 'should emit returning self' do
|
30
37
|
allow(Keen).to receive :publish
|
31
38
|
signup = TestSignup.new({})
|