jsonapi-resources 0.9.11 → 0.9.12

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
  SHA256:
3
- metadata.gz: eb4334bc31d044c34bc94da87c16e9e3aa91b9289b18bd13690ae2f3ff179f56
4
- data.tar.gz: 621418ce69f3d7de1d5874f0fcc85549cd80ea5d9798ed610a92571d126773da
3
+ metadata.gz: bfb7891ac7686be582e0831afd808f08504e492998968e704de2086c1656e9af
4
+ data.tar.gz: edeb27a90bec0a6fc79f67e0311cdf7e588fdcf347426489c21d94bcd40a3f28
5
5
  SHA512:
6
- metadata.gz: 6dff4f41d1dcb5452bddb882de80519a393e0e74f09aab94f1b0afc334c609603ffe3edfab252fdfcdfb859d8a053000bda275fd98d483bab88ca58cce9441a1
7
- data.tar.gz: 4a19057381f81e6699dc689fc34331bac63df876ff3033d33f38ddbba9cf09aeecf0eaa09eb7a762cad489b7242f94985a76175ab92399ced5f45774d43bc18a
6
+ metadata.gz: 645534a3b1811e939fb6e36098e7624072793b59a39eecc99b05743ff77e91289ca6b35441c614220833049b689f8bcf7b6b6fb9fb1f09190b239b706b3d2da7
7
+ data.tar.gz: 7b562179f5f6ab17179c71208838fccaa1703d6c88eb99356075daa255a57242f59972e5ba0118740d4d80f7bc5706f2f87b4e99b0840cca32d00b19056f5712
@@ -29,7 +29,7 @@ module JSONAPI
29
29
  def primary_resources_url
30
30
  if @primary_resource_klass._routed
31
31
  primary_resources_path = resources_path(primary_resource_klass)
32
- @primary_resources_url_cached ||= "#{ base_url }#{ engine_mount_point }#{ primary_resources_path }"
32
+ @primary_resources_url_cached ||= "#{ base_url }#{ serialized_engine_mount_point }#{ primary_resources_path }"
33
33
  else
34
34
  if JSONAPI.configuration.warn_on_missing_routes && !@primary_resource_klass._warned_missing_route
35
35
  warn "primary_resources_url for #{@primary_resource_klass} could not be generated"
@@ -139,7 +139,11 @@ module JSONAPI
139
139
  end
140
140
 
141
141
  def resource_url(source)
142
- "#{ base_url }#{ engine_mount_point }#{ resource_path(source) }"
142
+ "#{ base_url }#{ serialized_engine_mount_point }#{ resource_path(source) }"
143
+ end
144
+
145
+ def serialized_engine_mount_point
146
+ engine_mount_point == "/" ? "" : engine_mount_point
143
147
  end
144
148
 
145
149
  def route_for_relationship(relationship)
@@ -55,8 +55,14 @@ module JSONAPI
55
55
 
56
56
  def type_for_source(source)
57
57
  if polymorphic?
58
- resource = source.public_send(name)
59
- resource.class._type if resource
58
+ # try polymorphic type column before asking it from the resource record
59
+ if source._model.respond_to?(polymorphic_type)
60
+ model_type = source._model.send(polymorphic_type)
61
+ source.class.resource_for(model_type)._type if model_type
62
+ else
63
+ resource = source.public_send(name)
64
+ resource.class._type if resource
65
+ end
60
66
  else
61
67
  type
62
68
  end
@@ -291,7 +291,7 @@ module JSONAPI
291
291
  return @errors.concat(Exceptions::FilterNotAllowed.new(filter_method).errors)
292
292
  end
293
293
 
294
- verified_filter = relationship.resource_klass.verify_filters(filter_method => value)
294
+ verified_filter = relationship.resource_klass.verify_filters({ filter_method => value }, @context)
295
295
  @include_directives.merge_filter(relationship.name, verified_filter)
296
296
  else
297
297
  return @errors.concat(Exceptions::FilterNotAllowed.new(filter_method).errors)
@@ -314,7 +314,7 @@ module JSONAPI
314
314
 
315
315
  sorts = []
316
316
  begin
317
- raw = URI.unescape(sort_criteria)
317
+ raw = URI::DEFAULT_PARSER.unescape(sort_criteria)
318
318
  sorts += CSV.parse_line(raw)
319
319
  rescue CSV::MalformedCSVError
320
320
  fail JSONAPI::Exceptions::InvalidSortCriteria.new(format_key(@resource_klass._type), raw)
@@ -5,10 +5,10 @@ module JSONAPI
5
5
  ActionController::Rendering,
6
6
  ActionController::Renderers::All,
7
7
  ActionController::StrongParameters,
8
- ActionController::ForceSSL,
8
+ Gem::Requirement.new('< 6.1').satisfied_by?(ActionPack.gem_version) ? ActionController::ForceSSL : nil,
9
9
  ActionController::Instrumentation,
10
10
  JSONAPI::ActsAsResourceController
11
- ].freeze
11
+ ].compact.freeze
12
12
 
13
13
  MODULES.each do |mod|
14
14
  include mod
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Resources
3
- VERSION = '0.9.11'
3
+ VERSION = '0.9.12'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gebhardt
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-11 00:00:00.000000000 Z
12
+ date: 2021-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 1.17.3
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 1.17.3
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement