Class: JSONAPI::Configuration
- Inherits:
-
Object
- Object
- JSONAPI::Configuration
- Defined in:
- lib/json_api/configuration.rb
Instance Attribute Summary collapse
-
#authorization_handler ⇒ Object
Returns the value of attribute authorization_handler.
-
#authorization_scope ⇒ Object
Returns the value of attribute authorization_scope.
-
#default_page_size ⇒ Object
Returns the value of attribute default_page_size.
-
#document_meta_resolver ⇒ Object
Returns the value of attribute document_meta_resolver.
-
#jsonapi_meta ⇒ Object
Returns the value of attribute jsonapi_meta.
-
#max_page_size ⇒ Object
Returns the value of attribute max_page_size.
Instance Method Summary collapse
- #base_controller_class ⇒ Object
- #base_controller_class=(value) ⇒ Object
- #base_controller_overridden? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #resolved_base_controller_class ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 |
# File 'lib/json_api/configuration.rb', line 8 def initialize @default_page_size = 25 @max_page_size = 100 @jsonapi_meta = nil @authorization_handler = nil @authorization_scope = nil @document_meta_resolver = ->(controller:) { {} } # rubocop:disable Lint/UnusedBlockArgument @base_controller_class = "ActionController::API" end |
Instance Attribute Details
#authorization_handler ⇒ Object
Returns the value of attribute authorization_handler.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def @authorization_handler end |
#authorization_scope ⇒ Object
Returns the value of attribute authorization_scope.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def @authorization_scope end |
#default_page_size ⇒ Object
Returns the value of attribute default_page_size.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def default_page_size @default_page_size end |
#document_meta_resolver ⇒ Object
Returns the value of attribute document_meta_resolver.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def @document_meta_resolver end |
#jsonapi_meta ⇒ Object
Returns the value of attribute jsonapi_meta.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def @jsonapi_meta end |
#max_page_size ⇒ Object
Returns the value of attribute max_page_size.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def max_page_size @max_page_size end |
Instance Method Details
#base_controller_class ⇒ Object
34 35 36 |
# File 'lib/json_api/configuration.rb', line 34 def base_controller_class @base_controller_class.constantize end |
#base_controller_class=(value) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/json_api/configuration.rb', line 18 def base_controller_class=(value) if value.is_a?(Class) @base_controller_class = value.name elsif value.is_a?(String) raise ArgumentError, "base_controller_class cannot be blank" if value.nil? || value.strip.empty? @base_controller_class = value else raise ArgumentError, "base_controller_class must be a string or class" end return unless Rails.application&.initialized? JSONAPI.rebuild_base_controllers! end |
#base_controller_overridden? ⇒ Boolean
45 46 47 |
# File 'lib/json_api/configuration.rb', line 45 def base_controller_overridden? @base_controller_class != "ActionController::API" end |
#resolved_base_controller_class ⇒ Object
38 39 40 41 42 43 |
# File 'lib/json_api/configuration.rb', line 38 def resolved_base_controller_class class_name = @base_controller_class raise ArgumentError, "base_controller_class cannot be blank" if class_name.nil? || class_name.empty? class_name.constantize end |