Class: RESTFramework::Config

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

Overview

Global configuration should be kept minimal, as controller-level configurations allows multiple APIs to be defined to behave differently.

Constant Summary collapse

DEFAULT_EXCLUDE_ASSOCIATION_CLASSES =
%w(
  ActionText::RichText
  ActiveStorage::Attachment
  ActiveStorage::Blob
).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



56
57
58
59
# File 'lib/rest_framework.rb', line 56

def initialize
  self.show_backtrace = Rails.env.development?
  self.exclude_association_classes = DEFAULT_EXCLUDE_ASSOCIATION_CLASSES
end

Instance Attribute Details

#disable_auto_finalizeObject

Do not run ‘rrf_finalize` on controllers automatically using a `TracePoint` hook. This is a performance option and must be global because we have to determine this before any controller-specific configuration is set. If this is set to `true`, then you must manually call `rrf_finalize` after any configuration on each controller that needs to participate in:

- Model delegation, for the helper methods to be defined dynamically.
- Websockets, for `::Channel` class to be defined dynamically.
- Controller configuration freezing.


38
39
40
# File 'lib/rest_framework.rb', line 38

def disable_auto_finalize
  @disable_auto_finalize
end

#disable_rescue_fromObject

Option to disable ‘rescue_from` on the controller mixins.



51
52
53
# File 'lib/rest_framework.rb', line 51

def disable_rescue_from
  @disable_rescue_from
end

#exclude_association_classesObject

Options to exclude certain classes from being added by default as association fields.



54
55
56
# File 'lib/rest_framework.rb', line 54

def exclude_association_classes
  @exclude_association_classes
end

#freeze_configObject

Freeze configuration attributes during finalization to prevent accidental mutation.



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

def freeze_config
  @freeze_config
end

#large_reverse_association_tablesObject

Specify reverse association tables that are typically very large, andd therefore should not be added to fields by default.



45
46
47
# File 'lib/rest_framework.rb', line 45

def large_reverse_association_tables
  @large_reverse_association_tables
end

#show_backtraceObject

Whether the backtrace should be shown in rescued errors.



48
49
50
# File 'lib/rest_framework.rb', line 48

def show_backtrace
  @show_backtrace
end