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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37c468cb360cd83c3a7ba117322fc4e14c45b17b
4
- data.tar.gz: 1f0a60382362b5d5297f855ad642f8ff8c0accc6
3
+ metadata.gz: 69c773e23a25636e39c6a9fa5d509ede5915cc2e
4
+ data.tar.gz: d2dcfa3496a4dc19519bf7472ed0250948fe8870
5
5
  SHA512:
6
- metadata.gz: 70cd16daa9cc9ee9d4d7f2e56b1e54807036831ce91d18f0caa16f1ed86cc84eac9191aee6b59794b013789ac453c38b334ec5a29b045704f92b9e3f9a37df22
7
- data.tar.gz: 0d1358375f898228fa6276cc11221cb05867066b87a16fad1a5d7f82b1faff14af57285cf39cd00da4ac2981090eb817fb7de7cda2c06addd4b60475af814a1e
6
+ metadata.gz: df141569de0cf50b2597916fa0d3a4f210c7e9480537c234355be7619fc0e00bbf5f09c35cde13362a77d0b5a872b44010aef21188c78001997f87672494ac4e
7
+ data.tar.gz: ef61fb2dc42865334b6ef5fe06efa762f4d40ee9f997f0b6573477624c785d2227f1a2a85b24c6e4e37a6af4be24bfd7126e197f8dea99decc624308bcd7ca7a
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Lookist
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
3
3
  end
@@ -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.10
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-02 00:00:00.000000000 Z
12
+ date: 2014-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler