Class: RESTFramework::Config
- Inherits:
-
Object
- Object
- RESTFramework::Config
- 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
-
#disable_auto_finalize ⇒ Object
Do not run ‘rrf_finalize` on controllers automatically using a `TracePoint` hook.
-
#disable_rescue_from ⇒ Object
Disable ‘rescue_from` on the controller mixins.
-
#exclude_association_classes ⇒ Object
Exclude certain classes from being added by default as association fields.
-
#freeze_config ⇒ Object
Freeze configuration attributes during finalization to prevent accidental mutation.
-
#label_fields ⇒ Object
The default label fields to use when generating labels for ‘has_many` associations.
-
#large_reverse_association_tables ⇒ Object
Specify reverse association tables that are typically very large, andd therefore should not be added to fields by default.
-
#search_columns ⇒ Object
The default search columns to use when generating search filters.
-
#show_backtrace ⇒ Object
Whether the backtrace should be shown in rescued errors.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
60 61 62 63 64 65 |
# File 'lib/rest_framework.rb', line 60 def initialize self.show_backtrace = Rails.env.development? self.exclude_association_classes = DEFAULT_EXCLUDE_ASSOCIATION_CLASSES self.label_fields = DEFAULT_LABEL_FIELDS self.search_columns = DEFAULT_SEARCH_COLUMNS end |
Instance Attribute Details
#disable_auto_finalize ⇒ Object
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.
36 37 38 |
# File 'lib/rest_framework.rb', line 36 def disable_auto_finalize @disable_auto_finalize end |
#disable_rescue_from ⇒ Object
Disable ‘rescue_from` on the controller mixins.
49 50 51 |
# File 'lib/rest_framework.rb', line 49 def disable_rescue_from @disable_rescue_from end |
#exclude_association_classes ⇒ Object
Exclude certain classes from being added by default as association fields.
52 53 54 |
# File 'lib/rest_framework.rb', line 52 def exclude_association_classes @exclude_association_classes end |
#freeze_config ⇒ Object
Freeze configuration attributes during finalization to prevent accidental mutation.
39 40 41 |
# File 'lib/rest_framework.rb', line 39 def freeze_config @freeze_config end |
#label_fields ⇒ Object
The default label fields to use when generating labels for ‘has_many` associations.
55 56 57 |
# File 'lib/rest_framework.rb', line 55 def label_fields @label_fields end |
#large_reverse_association_tables ⇒ Object
Specify reverse association tables that are typically very large, andd therefore should not be added to fields by default.
43 44 45 |
# File 'lib/rest_framework.rb', line 43 def large_reverse_association_tables @large_reverse_association_tables end |
#search_columns ⇒ Object
The default search columns to use when generating search filters.
58 59 60 |
# File 'lib/rest_framework.rb', line 58 def search_columns @search_columns end |
#show_backtrace ⇒ Object
Whether the backtrace should be shown in rescued errors.
46 47 48 |
# File 'lib/rest_framework.rb', line 46 def show_backtrace @show_backtrace end |