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 +4 -4
- data/lib/hash19/core.rb +4 -0
- data/lib/hash19/version.rb +1 -1
- data/spec/hash19/access_spec.rb +28 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2690fb2383e0fb03cf39844a44cee0f8761af48c
|
4
|
+
data.tar.gz: 430b9b351c64625827b3f4994a8cfed9ca2002ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 662633e7af29b3d2eb31dba44e4cc11c2bc615b95dad1b20fa7e566bee0f512180ee1c83bae39d1166fc15d6f7506fd3827a8a7daccd469aca1af9aa07e2976c
|
7
|
+
data.tar.gz: 7531bcbd9375ccca4fc60fca9b74862192c49296bbedd6bd083ec4c50d1c195357cc354dc5c7f89a6fcd794fc0dcb5e1e2c15e0176f0fe3ce785125b62a1b0bc
|
data/lib/hash19/core.rb
CHANGED
data/lib/hash19/version.rb
CHANGED
@@ -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.
|
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
|
+
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
|