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.
-
#namespace_fallback ⇒ Object
Returns the value of attribute namespace_fallback.
-
#namespace_model_mapping ⇒ Object
Returns the value of attribute namespace_model_mapping.
-
#namespace_type_format ⇒ Object
Returns the value of attribute namespace_type_format.
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.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/json_api/configuration.rb', line 9 def initialize @default_page_size = 25 @max_page_size = 100 = nil = nil = nil = ->(controller:) { {} } # rubocop:disable Lint/UnusedBlockArgument @base_controller_class = "ActionController::API" @namespace_type_format = :flat @namespace_model_mapping = :same_namespace @namespace_fallback = true 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 end |
#authorization_scope ⇒ Object
Returns the value of attribute authorization_scope.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def 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 end |
#jsonapi_meta ⇒ Object
Returns the value of attribute jsonapi_meta.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def 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 |
#namespace_fallback ⇒ Object
Returns the value of attribute namespace_fallback.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def namespace_fallback @namespace_fallback end |
#namespace_model_mapping ⇒ Object
Returns the value of attribute namespace_model_mapping.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def namespace_model_mapping @namespace_model_mapping end |
#namespace_type_format ⇒ Object
Returns the value of attribute namespace_type_format.
5 6 7 |
# File 'lib/json_api/configuration.rb', line 5 def namespace_type_format @namespace_type_format end |
Instance Method Details
#base_controller_class ⇒ Object
38 39 40 |
# File 'lib/json_api/configuration.rb', line 38 def base_controller_class @base_controller_class.constantize end |
#base_controller_class=(value) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/json_api/configuration.rb', line 22 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
49 50 51 |
# File 'lib/json_api/configuration.rb', line 49 def base_controller_overridden? @base_controller_class != "ActionController::API" end |
#resolved_base_controller_class ⇒ Object
42 43 44 45 46 47 |
# File 'lib/json_api/configuration.rb', line 42 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 |