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 =
[].freeze
DEFAULT_LABEL_FIELDS =
%w(name label login title email username url).freeze
DEFAULT_SEARCH_COLUMNS =
DEFAULT_LABEL_FIELDS + %w(description note).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



153
154
155
156
157
# File 'lib/rest_framework.rb', line 153

def initialize
  self.show_backtrace = Rails.env.development?
  self.label_fields = DEFAULT_LABEL_FIELDS
  self.search_columns = DEFAULT_SEARCH_COLUMNS
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.


128
129
130
# File 'lib/rest_framework.rb', line 128

def disable_auto_finalize
  @disable_auto_finalize
end

#disable_rescue_fromObject

Disable ‘rescue_from` on the controller mixins.



141
142
143
# File 'lib/rest_framework.rb', line 141

def disable_rescue_from
  @disable_rescue_from
end

#freeze_configObject

Freeze configuration attributes during finalization to prevent accidental mutation.



131
132
133
# File 'lib/rest_framework.rb', line 131

def freeze_config
  @freeze_config
end

#label_fieldsObject

The default label fields to use when generating labels for ‘has_many` associations.



144
145
146
# File 'lib/rest_framework.rb', line 144

def label_fields
  @label_fields
end

#large_reverse_association_tablesObject

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



135
136
137
# File 'lib/rest_framework.rb', line 135

def large_reverse_association_tables
  @large_reverse_association_tables
end

#search_columnsObject

The default search columns to use when generating search filters.



147
148
149
# File 'lib/rest_framework.rb', line 147

def search_columns
  @search_columns
end

#show_backtraceObject

Whether the backtrace should be shown in rescued errors.



138
139
140
# File 'lib/rest_framework.rb', line 138

def show_backtrace
  @show_backtrace
end

#use_vendored_assetsObject

Option to use vendored assets (requires sprockets or propshaft) rather than linking to external assets (the default).



151
152
153
# File 'lib/rest_framework.rb', line 151

def use_vendored_assets
  @use_vendored_assets
end