Method: JSONAPI::Configuration#initialize
- Defined in:
- lib/jsonapi/configuration.rb
#initialize ⇒ Configuration
Returns a new instance of Configuration.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/jsonapi/configuration.rb', line 37 def initialize #:underscored_key, :camelized_key, :dasherized_key, or custom self.json_key_format = :dasherized_key #:underscored_route, :camelized_route, :dasherized_route, or custom self.route_format = :dasherized_route #:integer, :uuid, :string, or custom (provide a proc) self.resource_key_type = :integer # optional request features self.allow_include = true self.allow_sort = true self.allow_filter = true self.raise_if_parameters_not_allowed = true # :none, :offset, :paged, or a custom paginator name self.default_paginator = :none # Output pagination links at top level self.top_level_links_include_pagination = true self.default_page_size = 10 self.maximum_page_size = 20 # Metadata # Output record count in top level meta for find operation self. = false self. = :record_count self. = false self. = :page_count self.use_text_errors = false # Whether or not to include exception backtraces in JSONAPI error # responses. Defaults to `false` in production, and `true` otherwise. self.include_backtraces_in_errors = !Rails.env.production? # List of classes that should not be rescued by the operations processor. # For example, if you use Pundit for authorization, you might # raise a Pundit::NotAuthorizedError at some point during operations # processing. If you want to use Rails' `rescue_from` macro to # catch this error and render a 403 status code, you should add # the `Pundit::NotAuthorizedError` to the `exception_class_whitelist`. self.exception_class_whitelist = [] # If enabled, will override configuration option `exception_class_whitelist` # and whitelist all exceptions. self.whitelist_all_exceptions = false # Resource Linkage # Controls the serialization of resource linkage for non compound documents # NOTE: always_include_to_many_linkage_data is not currently implemented self.always_include_to_one_linkage_data = false self.always_include_to_many_linkage_data = false # The default Operation Processor to use if one is not defined specifically # for a Resource. self.default_processor_klass = JSONAPI::Processor # Allows transactions for creating and updating records # Set this to false if your backend does not support transactions (e.g. Mongodb) self.allow_transactions = true # Formatter Caching # Set to false to disable caching of string operations on keys and links. # Note that unlike the resource cache, formatter caching is always done # internally in-memory and per-thread; no ActiveSupport::Cache is used. self.cache_formatters = true # Relationship reflection invokes the related resource when updates # are made to a has_many relationship. By default relationship_reflection # is turned off because it imposes a small performance penalty. self.use_relationship_reflection = false # Resource cache # An ActiveSupport::Cache::Store or similar, used by Resources with caching enabled. # Set to `nil` (the default) to disable caching, or to `Rails.cache` to use the # Rails cache store. self.resource_cache = nil # Default resource cache field # On Resources with caching enabled, this field will be used to check for out-of-date # cache entries, unless overridden on a specific Resource. Defaults to "updated_at". self.default_resource_cache_field = :updated_at # Resource cache digest function # Provide a callable that returns a unique value for string inputs with # low chance of collision. The default is SHA256 base64. self.resource_cache_digest_function = Digest::SHA2.new.method(:base64digest) # Resource cache usage reporting # Optionally provide a callable which JSONAPI will call with information about cache # performance. Should accept three arguments: resource name, hits count, misses count. self.resource_cache_usage_report_function = nil end |