Skip to content

Commit 56da6f7

Browse files
committed
Fix configuration.
1 parent 2597d0f commit 56da6f7

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

lib/generators/jsonapi/initializer/templates/initializer.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
# }
2323
#
2424
# # Set default exposures.
25-
# config.jsonapi_expose = {
26-
# url_helpers: ::Rails.application.routes.url_helpers
25+
# # A lambda/proc that will be eval'd in the controller context.
26+
# config.jsonapi_expose = lambda {
27+
# { url_helpers: ::Rails.application.routes.url_helpers }
2728
# }
2829
#
2930
# # Set a default pagination scheme.

lib/jsonapi/rails.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
require 'jsonapi/deserializable'
22
require 'jsonapi/serializable'
3+
require 'jsonapi/rails/configuration'
34
require 'jsonapi/rails/railtie'

lib/jsonapi/rails/configuration.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Configuration < ActiveSupport::InheritableOptions; end
2020
version: '1.0'
2121
}.freeze
2222

23-
DEFAULT_JSONAPI_EXPOSE = {
24-
url_helpers: ::Rails.application.routes.url_helpers
23+
DEFAULT_JSONAPI_EXPOSE = lambda {
24+
{ url_helpers: ::Rails.application.routes.url_helpers }
2525
}.freeze
2626

2727
DEFAULT_JSONAPI_PAGINATION = ->(_) { nil }

lib/jsonapi/rails/controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def jsonapi_object
107107
# Hook for default exposures.
108108
# @return [Hash]
109109
def jsonapi_expose
110-
JSONAPI::Rails.config[:jsonapi_expose]
110+
instance_exec(&JSONAPI::Rails.config[:jsonapi_expose])
111111
end
112112

113113
# Hook for pagination scheme.

0 commit comments

Comments
 (0)