perry 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -14,11 +14,11 @@ module Perry::Adapters
|
|
14
14
|
attr_reader :last_response
|
15
15
|
|
16
16
|
def read(options)
|
17
|
-
get_http(options[:relation])
|
18
|
-
|
19
|
-
|
20
|
-
end
|
17
|
+
response = get_http(options[:relation])
|
18
|
+
unless response.parsed.is_a?(Array)
|
19
|
+
raise Perry::MalformedResponse, "Expected instance of Array got '#{response.raw.inspect}'"
|
21
20
|
end
|
21
|
+
response.array_attributes
|
22
22
|
end
|
23
23
|
|
24
24
|
def write(options)
|
@@ -49,11 +49,15 @@ module Perry::Persistence
|
|
49
49
|
|
50
50
|
def model_attributes
|
51
51
|
# return the inner hash if nested
|
52
|
-
|
53
|
-
|
52
|
+
extract_attributes(parsed_hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
def array_attributes
|
56
|
+
if parsed.is_a?(Array)
|
57
|
+
parsed.collect { |item| item.is_a?(Hash) ? extract_attributes(item) : item }
|
54
58
|
else
|
55
|
-
|
56
|
-
end
|
59
|
+
[]
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
def errors
|
@@ -62,6 +66,14 @@ module Perry::Persistence
|
|
62
66
|
|
63
67
|
protected
|
64
68
|
|
69
|
+
def extract_attributes(hash)
|
70
|
+
if hash.keys.size == 1 && hash[hash.keys.first].is_a?(Hash)
|
71
|
+
hash[hash.keys.first]
|
72
|
+
else
|
73
|
+
hash
|
74
|
+
end.symbolize_keys
|
75
|
+
end
|
76
|
+
|
65
77
|
def parsed_hash
|
66
78
|
if parsed.is_a?(Hash)
|
67
79
|
parsed
|
data/lib/perry/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 2
|
10
|
+
version: 0.6.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Travis Petticrew
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: shoulda
|