medea 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/medea/jasondeferredquery.rb +19 -29
- data/lib/medea/version.rb +1 -1
- metadata +3 -3
@@ -113,39 +113,29 @@ module Medea
|
|
113
113
|
def execute_query content=true
|
114
114
|
#hit the URL
|
115
115
|
#fill self.contents with :ghost versions of JasonObjects
|
116
|
-
|
117
|
-
LOGGER.debug "Executing #{type.name} deferred query! (#{to_url})"
|
116
|
+
LOGGER.debug "Executing #{type.name} deferred query! (#{to_url})"
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
131
|
-
if result[k].has_key?("HTTP_X_PARENT") && result[k]["HTTP_X_PARENT"] != ""
|
132
|
-
item.jason_parent_key = result[k]["HTTP_X_PARENT"]
|
133
|
-
end
|
134
|
-
self.contents << item
|
118
|
+
response = RestClient.get to_url
|
119
|
+
result = JSON.parse(response)
|
120
|
+
self.contents = []
|
121
|
+
#results are in a hash, their keys are just numbers
|
122
|
+
result.keys.each do |k|
|
123
|
+
if k =~ /^[0-9]+$/
|
124
|
+
#this is a result! get the key
|
125
|
+
item = type.new(result[k]["HTTP_X_KEY"], :lazy)
|
126
|
+
if content && result[k].has_key?("CONTENT") && result[k]["CONTENT"] != ""
|
127
|
+
item.instance_variable_set(:@__jason_data, result[k]["CONTENT"])
|
128
|
+
item.instance_variable_set(:@__jason_state, :stale)
|
135
129
|
end
|
130
|
+
if result[k].has_key?("HTTP_X_PARENT") && result[k]["HTTP_X_PARENT"] != ""
|
131
|
+
item.jason_parent_key = result[k]["HTTP_X_PARENT"]
|
132
|
+
end
|
133
|
+
self.contents << item
|
136
134
|
end
|
137
|
-
|
138
|
-
self.state = :postfetch
|
139
|
-
result
|
140
|
-
rescue
|
141
|
-
if response.code != 200
|
142
|
-
LOGGER.error "Query to #{to_url} failed to parse!"
|
143
|
-
else
|
144
|
-
LOGGER.error "Query to #{to_url} failed to get!"
|
145
|
-
end
|
146
|
-
|
147
|
-
self.contents = []
|
148
135
|
end
|
136
|
+
|
137
|
+
self.state = :postfetch
|
138
|
+
result
|
149
139
|
end
|
150
140
|
end
|
151
141
|
end
|
data/lib/medea/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: medea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Jensen
|