hash19 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: a7e8cb858f281fe243f6313e0f9994a5eab13fc6
4
- data.tar.gz: e5c0f468c861235c25c5351a0b54b3e2994cc301
3
+ metadata.gz: 2690fb2383e0fb03cf39844a44cee0f8761af48c
4
+ data.tar.gz: 430b9b351c64625827b3f4994a8cfed9ca2002ea
5
5
  SHA512:
6
- metadata.gz: 4b23828ba566e076c310640f9b70005240bf54bf5e0f2d4ad865e0a3f6c44bcdebc98e5a6541f467fcca0d0f550f27656de771840697771a49c796330cef4832
7
- data.tar.gz: 6c647366fa43c37d68f5dcad640b97a097bf7e3480655fa9b2433f5ed3b06c6b24b08f10fb2d264b30e6181c73e46fe26ec1febdbbe7dd89b4d7496c39f7e5ac
6
+ metadata.gz: 662633e7af29b3d2eb31dba44e4cc11c2bc615b95dad1b20fa7e566bee0f512180ee1c83bae39d1166fc15d6f7506fd3827a8a7daccd469aca1af9aa07e2976c
7
+ data.tar.gz: 7531bcbd9375ccca4fc60fca9b74862192c49296bbedd6bd083ec4c50d1c195357cc354dc5c7f89a6fcd794fc0dcb5e1e2c15e0176f0fe3ce785125b62a1b0bc
data/lib/hash19/core.rb CHANGED
@@ -31,6 +31,10 @@ module Hash19
31
31
  klass.send :prepend, Initializer
32
32
  end
33
33
 
34
+ def [](key)
35
+ @hash19[key]
36
+ end
37
+
34
38
  def to_h(lazy:false)
35
39
  return @hash19 if lazy
36
40
  if @hash19.is_a? Array
@@ -1,3 +1,3 @@
1
1
  module Hash19
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Access Patterns for Hash19' do
4
+
5
+ class Hash1
6
+ include Hash19
7
+ attributes :a, :b, :c
8
+ end
9
+
10
+ it 'should be able to access hash keys using dot notation' do
11
+ hash1 = Hash1.new({a: 1, b: 2, c: 3})
12
+ expect(hash1[:a]).to eq(1)
13
+ expect(hash1[:b]).to eq(2)
14
+ expect(hash1[:c]).to eq(3)
15
+ end
16
+
17
+ class Hash11
18
+ include Hash19
19
+ attributes :x, :y
20
+ has_one :hash1, alias: :h
21
+ end
22
+
23
+ it 'should be able to work recursively' do
24
+ hash11 = Hash11.new(hash1: {a: 1, b: 2, c: 3}, x: -1, y: -2)
25
+ expect(hash11[:h][:a]).to eq(1)
26
+ end
27
+
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash19
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
  - RC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - lib/hash19/lazy_value.rb
132
132
  - lib/hash19/resolvers.rb
133
133
  - lib/hash19/version.rb
134
+ - spec/hash19/access_spec.rb
134
135
  - spec/hash19/associations_spec.rb
135
136
  - spec/hash19/contains_spec.rb
136
137
  - spec/hash19/core_spec.rb
@@ -163,6 +164,7 @@ specification_version: 4
163
164
  summary: Hash helpers to map complex JSON to ruby objects. Handles associations and
164
165
  eager loading and collection injection
165
166
  test_files:
167
+ - spec/hash19/access_spec.rb
166
168
  - spec/hash19/associations_spec.rb
167
169
  - spec/hash19/contains_spec.rb
168
170
  - spec/hash19/core_spec.rb