ocean-rails 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8d0e06a51eb9695e45cbd3117875807398ad746
4
- data.tar.gz: bc840097a5de048b4b8256ad656b8618abb1a4b5
3
+ metadata.gz: 58b7c59491b48aac2169a883e6ce85cf34e74264
4
+ data.tar.gz: 31e64b09dd45ee2de000c966957f9f56c5ff7158
5
5
  SHA512:
6
- metadata.gz: f72419c440325db8eb7d82f9d5f397c93e0c007c068738ab00842246a70a7619a7ca067f54b3d6f562bf25adc8a41685eec066a069a2e3dbc8ad130736f2d63d
7
- data.tar.gz: dff353241989bd4c3bbb4a8ff65e6e93b5bb6640698d0cd808c6f5201a9cfc58e2a3067e7796394458a00b9bbf77754cb80e364ac05d611c58c4dbca051c622e
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(:where, :order, :limit, :offset, :group, :having).count,
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
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson