structure 0.25.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/structure/version.rb +1 -1
- data/lib/structure.rb +4 -1
- data/test/structure_test.rb +23 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d836fcee886c983c153695e9d454e42b8ff53ee
|
4
|
+
data.tar.gz: 1b7ebe258505000bb9156f672959ddfaae5608c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1d7492bc4806441940ec83dca67afef6e445112cf8d025d6326fdc9b65b59300c8dcddd0a8510abb9ae7eff26a870a2151035478e5aa9e101a8994faf4ed4f
|
7
|
+
data.tar.gz: d054f3f46d0759b1fa1044ee56357e77f361bf0fd53b1253d3e683bc4ef579762cb5ca92d48c628183c4363b7198ef8af5b8ee63b536c70c024c0a3c13892871
|
data/.gitignore
CHANGED
data/lib/structure/version.rb
CHANGED
data/lib/structure.rb
CHANGED
data/test/structure_test.rb
CHANGED
@@ -57,4 +57,27 @@ class StructureTest < MiniTest::Test
|
|
57
57
|
|
58
58
|
assert_equal({ latitude: 10, longitude: 100, name: 'foo' }, obj.values)
|
59
59
|
end
|
60
|
+
|
61
|
+
def test_recursively_casts_to_hash
|
62
|
+
city_class = Class.new do
|
63
|
+
include Structure
|
64
|
+
|
65
|
+
attr :res
|
66
|
+
|
67
|
+
def initialize(res)
|
68
|
+
@res = res
|
69
|
+
end
|
70
|
+
|
71
|
+
value :name do
|
72
|
+
res.fetch(:name)
|
73
|
+
end
|
74
|
+
|
75
|
+
value :location do
|
76
|
+
Location.new(res.fetch(:loc))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
city = city_class.new(name: 'London', loc: { lat: 51.5, lng: 0.1 })
|
81
|
+
assert_equal({ name: 'London', location: { latitude: 51.5, longitude: 0.1 }}, city.to_h)
|
82
|
+
end
|
60
83
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Value objects in Ruby
|
@@ -45,7 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE
|
51
51
|
- README.md
|
@@ -64,17 +64,17 @@ require_paths:
|
|
64
64
|
- lib
|
65
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.0
|
77
|
+
rubygems_version: 2.2.0
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Value objects in Ruby
|