jsos 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -0
- data/jsos.gemspec +1 -1
- data/lib/jsos.rb +11 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9412f7bbfd53a242bd550d7a7b9369a1bb61baf
|
4
|
+
data.tar.gz: de58cc657d6a008c89476e05fb8203acd3b993a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5463f4da5331a4c2b5501308a2481c8ca57daacc070b6fe8e8e1ffbc740a31b002eee4cd57ce73e88aa01ecfec3a170e5bca5e6b29dc07031d46b306f5b88c3c
|
7
|
+
data.tar.gz: bc204f6bdf1b43be6fd98ff5e15c872af2845f4425a2b84c5f4e20d4aeff7cee3fafc74cc30e34367088d03d54269e3760673068d0a874e2c30de92d52ed36ff
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# JSOS
|
2
2
|
[![Build Status](https://travis-ci.org/jdenen/jsos.svg?branch=master)](https://travis-ci.org/jdenen/jsos)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jsos.svg)](https://badge.fury.io/rb/jsos)
|
3
4
|
|
4
5
|
Use Ruby's OpenStruct object to represent JSON strings, making nested data a method call away.
|
5
6
|
|
data/jsos.gemspec
CHANGED
data/lib/jsos.rb
CHANGED
@@ -42,7 +42,9 @@ class JSOS < OpenStruct
|
|
42
42
|
|
43
43
|
# @param state [String|Hash] defaults to nil
|
44
44
|
def initialize(state = nil)
|
45
|
-
|
45
|
+
return super if state.nil?
|
46
|
+
state_hash = state.is_a?(String) ? JSON.parse(state) : state
|
47
|
+
super parse_state_hash(state_hash)
|
46
48
|
end
|
47
49
|
|
48
50
|
# @return [Hash]
|
@@ -83,4 +85,12 @@ class JSOS < OpenStruct
|
|
83
85
|
def make_setter getter
|
84
86
|
getter.to_s.concat('=').to_sym
|
85
87
|
end
|
88
|
+
|
89
|
+
# @api private
|
90
|
+
def parse_state_hash state
|
91
|
+
state.inject({}) do |hash, (key, value)|
|
92
|
+
merge_value = value.is_a?(Hash) ? {key => JSOS.new(value)} : {key => value}
|
93
|
+
hash.merge(merge_value)
|
94
|
+
end
|
95
|
+
end
|
86
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnson Denen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- ".travis.yml"
|
106
|
+
- CHANGELOG.md
|
106
107
|
- Gemfile
|
107
108
|
- LICENSE.txt
|
108
109
|
- README.md
|