Class: JSONAPI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
# File 'lib/json_api/configuration.rb', line 10

def initialize
  set_defaults
end

Instance Attribute Details

#authorization_handlerObject

Returns the value of attribute authorization_handler.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def authorization_handler
  @authorization_handler
end

#authorization_scopeObject

Returns the value of attribute authorization_scope.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def authorization_scope
  @authorization_scope
end

#default_page_sizeObject

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_resolverObject

Returns the value of attribute document_meta_resolver.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def document_meta_resolver
  @document_meta_resolver
end

#jsonapi_metaObject

Returns the value of attribute jsonapi_meta.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def jsonapi_meta
  @jsonapi_meta
end

#max_page_sizeObject

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

#n1_query_thresholdObject

Returns the value of attribute n1_query_threshold.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def n1_query_threshold
  @n1_query_threshold
end

#n1_warning_enabledObject

Returns the value of attribute n1_warning_enabled.



5
6
7
# File 'lib/json_api/configuration.rb', line 5

def n1_warning_enabled
  @n1_warning_enabled
end

#namespace_fallbackObject

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_mappingObject

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_formatObject

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_classObject



30
31
32
# File 'lib/json_api/configuration.rb', line 30

def base_controller_class
  @base_controller_class.constantize
end

#base_controller_class=(value) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/json_api/configuration.rb', line 14

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

Returns:

  • (Boolean)


41
42
43
# File 'lib/json_api/configuration.rb', line 41

def base_controller_overridden?
  @base_controller_class != "ActionController::API"
end

#resolved_base_controller_classObject

Raises:

  • (ArgumentError)


34
35
36
37
38
39
# File 'lib/json_api/configuration.rb', line 34

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