ocean-rails 2.0.1 → 2.0.2
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.
- checksums.yaml +4 -4
- data/lib/ocean/ocean_application_controller.rb +9 -4
- data/lib/ocean/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58b7c59491b48aac2169a883e6ce85cf34e74264
|
4
|
+
data.tar.gz: 31e64b09dd45ee2de000c966957f9f56c5ff7158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40db8a263bf19a89fd63f6dedc14ef833f735992bde8619cd089d7f6c6ad7c6b18a3a68c4877e9bddbc7c5928d8d85f7ab81b76f4e90374496a1cf517ea6270
|
7
|
+
data.tar.gz: f27fa478cac0e998a45388009de1a97f8546ed41d37c6f4f221067371a2c6661603ffbafe63725abb933bcfa6ec1042e592be24995f27032af6b16e61e1ca94a
|
@@ -164,7 +164,7 @@ module OceanApplicationController
|
|
164
164
|
# their standard position, begin with an underscore, etc. The +ocean+ gem generator
|
165
165
|
# for resources creates a partial in the proper location.
|
166
166
|
#
|
167
|
-
def api_render(x, new: false)
|
167
|
+
def api_render(x, new: false, href: url_for(params))
|
168
168
|
if !x.is_a?(Array) && !(defined?(ActiveRecord) && x.is_a?(ActiveRecord::Relation))
|
169
169
|
partial = x.to_partial_path
|
170
170
|
if new
|
@@ -177,10 +177,15 @@ module OceanApplicationController
|
|
177
177
|
resources = x.collect { |m| render_to_string(partial: m.to_partial_path,
|
178
178
|
locals: {m.class.model_name.i18n_key => m}) }
|
179
179
|
attrs = {count: resources.count,
|
180
|
-
total_count: x.unscope(
|
181
|
-
_links: {self: {href: request.url, type: 'application/json'}
|
182
|
-
}
|
180
|
+
total_count: x.unscope(*ActiveRecord::QueryMethods::VALID_UNSCOPING_VALUES.to_a).count
|
183
181
|
}
|
182
|
+
links = {}
|
183
|
+
if href
|
184
|
+
links['self'] = {href: href, type: 'application/json'}
|
185
|
+
end
|
186
|
+
if links
|
187
|
+
attrs['_links'] = links
|
188
|
+
end
|
184
189
|
render text: '{"_collection":{"resources":[' + resources.join(',') + ']' +
|
185
190
|
(attrs.collect do |k, v|
|
186
191
|
',"' + k.to_s + '":' + v.to_json
|
data/lib/ocean/version.rb
CHANGED