looksist 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/looksist/hashed.rb +1 -1
- data/lib/looksist/version.rb +1 -1
- data/spec/looksist/hashed_spec.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69c773e23a25636e39c6a9fa5d509ede5915cc2e
|
4
|
+
data.tar.gz: d2dcfa3496a4dc19519bf7472ed0250948fe8870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df141569de0cf50b2597916fa0d3a4f210c7e9480537c234355be7619fc0e00bbf5f09c35cde13362a77d0b5a872b44010aef21188c78001997f87672494ac4e
|
7
|
+
data.tar.gz: ef61fb2dc42865334b6ef5fe06efa762f4d40ee9f997f0b6573477624c785d2227f1a2a85b24c6e4e37a6af4be24bfd7126e197f8dea99decc624308bcd7ca7a
|
data/lib/looksist/hashed.rb
CHANGED
@@ -156,7 +156,7 @@ module Looksist
|
|
156
156
|
if populate.is_a? Array
|
157
157
|
populate.collect do |_key|
|
158
158
|
alias_method = find_alias(as, _key)
|
159
|
-
parsed_key = JSON.parse(values[elt.with_indifferent_access[using]]).deep_symbolize_keys
|
159
|
+
parsed_key = JSON.parse(values[elt.with_indifferent_access[using]] || '{}').deep_symbolize_keys
|
160
160
|
elt[alias_method] = parsed_key[_key]
|
161
161
|
end
|
162
162
|
else
|
data/lib/looksist/version.rb
CHANGED
@@ -480,6 +480,33 @@ describe Looksist::Hashed do
|
|
480
480
|
)
|
481
481
|
end
|
482
482
|
|
483
|
+
it 'should work for multiple attributes with one returning nil' do
|
484
|
+
class HashWithMultipleAttributesWithNil
|
485
|
+
include Looksist
|
486
|
+
|
487
|
+
def metrics
|
488
|
+
[
|
489
|
+
{
|
490
|
+
hero_id: 1
|
491
|
+
},
|
492
|
+
{
|
493
|
+
hero_id: 2
|
494
|
+
}
|
495
|
+
]
|
496
|
+
end
|
497
|
+
|
498
|
+
inject after: :metrics, using: :hero_id, populate: [:name, :mnemonic], as: {name: 'hero_name', mnemonic: 'hero_mnemonic'}
|
499
|
+
end
|
500
|
+
js1 = {name: 'Rajini', mnemonic: 'SuperStart'}.to_json
|
501
|
+
jsons = [js1, nil]
|
502
|
+
expect(@mock).to receive(:mget).once.with(*%w(heros/1 heros/2)).and_return(jsons)
|
503
|
+
|
504
|
+
expect(HashWithMultipleAttributesWithNil.new.metrics).to eq(
|
505
|
+
[{:hero_id => 1, :hero_name => 'Rajini', :hero_mnemonic => 'SuperStart'},
|
506
|
+
{:hero_id => 2, :hero_name => nil, :hero_mnemonic => nil}]
|
507
|
+
)
|
508
|
+
end
|
509
|
+
|
483
510
|
it 'should work for class methods' do
|
484
511
|
class SelfHelp
|
485
512
|
include Looksist
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: looksist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RC
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|