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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8184a8ba4c90d62012e5628c1c91077f4685b5b4
4
- data.tar.gz: d2bb1770658dd080b076051b761680ca34848bd4
3
+ metadata.gz: 25d5b980ef324ae850b4a96e57c7f55bd4a61539
4
+ data.tar.gz: eaea905439f9e4445d7b124e04701bc7cec6f575
5
5
  SHA512:
6
- metadata.gz: 292b64c6560dd1fa577ee31f78eaf18bab59580c280ed7ab8faf6deeace68da271aead0959c800a93b58f06a8c12f7cd1698c2768005f050824646f25ceed48c
7
- data.tar.gz: 5de2832902fd924443b992a0a804a1232a6ead169a35fadfbd6c9fbc32c886a256bd07c8ea7539c06f7bae88978cb9fc304a1f66b631e82bf428a04eca3af9ea
6
+ metadata.gz: e9dafea998ef3affcfd00a5427d99ca256bd82e4892b60a7295e4cc024633ee162bb1fe8d36876a500fde79e83a37f37ff6f9ceeff982296d026410cd40968ad
7
+ data.tar.gz: 22a853b9b32d680fa05c891366f38d6b798c0a787a5a4be90966d294ca293df4779ccba03fa126a2b64b0175e55fb1a29fe6c0f133a88430347777a15dee9f8c
data/lib/nark/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nark
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/nark.rb CHANGED
@@ -6,12 +6,15 @@ module Nark
6
6
  klass.extend ClassMethods
7
7
  end
8
8
 
9
- attr_reader :serializable_hash
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, serializable_hash
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
- @serializable_hash = attributes
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({})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall