module Serega::SeregaConfig::SeregaConfigInstanceMethods
Config options
Public Instance Methods
() → { has_delegate_option: bool, has_serializer_option: bool }
Source
# File lib/serega/config.rb, line 137 def auto_preload opts.fetch(:auto_preload) end
Attributes that get preloads automatically: :delegate attributes with has_delegate_option and :serializer attributes with has_serializer_option. Both are false by default.
(bool | { ?has_delegate_option: bool, ?has_serializer_option: bool } value) → { has_delegate_option: bool, has_serializer_option: bool }
Source
# File lib/serega/config.rb, line 143 def auto_preload=(value) opts[:auto_preload] = case value when true then {has_delegate_option: true, has_serializer_option: true} when false then {has_delegate_option: false, has_serializer_option: false} when Hash SeregaValidations::Utils::CheckAllowedKeys.call(value, %i[has_delegate_option has_serializer_option], "auto_preload") {has_delegate_option: !!value[:has_delegate_option], has_serializer_option: !!value[:has_serializer_option]} else raise SeregaError, "Must have boolean value or Hash, #{value.inspect} provided" end end
Sets auto_preload: true or false for both kinds of attributes, or a Hash with has_delegate_option and has_serializer_option
() → Array[Symbol]
Source
# File lib/serega/config.rb, line 86 def auto_preload_excluded_methods opts.fetch(:auto_preload_excluded_methods) end
Methods that auto_preload never preloads, as they return the object itself. [:itself, :__getobj__] by default.
(Array[Symbol] value) → Array[Symbol]
Source
# File lib/serega/config.rb, line 91 def auto_preload_excluded_methods=(value) unless value.is_a?(Array) && value.all?(Symbol) raise SeregaError, "Must be an Array of Symbols, #{value.inspect} provided" end opts[:auto_preload_excluded_methods] = value end
() → singleton(Serega)?
Source
# File lib/serega/config.rb, line 101 def base_serializer opts.fetch(:base_serializer) end
Parent class of nested serializers defined with an attribute block. nil by default.
(singleton(Serega) value) → singleton(Serega)
Source
# File lib/serega/config.rb, line 110 def base_serializer=(value) raise SeregaError, "Must be a Serega subclass, #{value.inspect} provided" if !value.is_a?(Class) || !(value <= Serega) opts[:base_serializer] = value end
Sets base_serializer, a Serega subclass
config.base_serializer = self
() → Symbol
Source
# File lib/serega/config.rb, line 217 def batch_id_option opts.fetch(:batch_id_option) end
Method that returns the id of an object for batch loaders, :id by default
(Symbol value) → Symbol
Source
# File lib/serega/config.rb, line 222 def batch_id_option=(value) raise SeregaError, "Must have Symbol value, #{value.inspect} provided" unless value.is_a?(Symbol) opts[:batch_id_option] = value end
Sets batch_id_option
() → bool
Source
# File lib/serega/config.rb, line 195 def check_attribute_name opts.fetch(:check_attribute_name) end
Whether attribute names may contain only a-z, A-Z, 0-9, _, - and ~. true by default.
(bool value) → bool
Source
# File lib/serega/config.rb, line 200 def check_attribute_name=(value) opts[:check_attribute_name] = checked_boolean(value) end
Sets check_attribute_name
() → bool
Source
# File lib/serega/config.rb, line 64 def check_initiate_params opts.fetch(:check_initiate_params) end
Whether unknown fields of only:, except: and with: raise Serega::AttributeNotExist. true by default.
(bool value) → bool
Source
# File lib/serega/config.rb, line 69 def check_initiate_params=(value) opts[:check_initiate_params] = checked_boolean(value) end
() → bool
Source
# File lib/serega/config.rb, line 75 def delegate_default_allow_nil opts.fetch(:delegate_default_allow_nil) end
Default allow_nil: of the :delegate attribute option. false by default.
(bool value) → bool
Source
# File lib/serega/config.rb, line 80 def delegate_default_allow_nil=(value) opts[:delegate_default_allow_nil] = checked_boolean(value) end
() → Integer?
Source
# File lib/serega/config.rb, line 182 def depth_limit opts.fetch(:depth_limit) end
Deepest nesting of serialized fields, nil for no limit (the default). The limit of the serializer that starts the serialization applies.
(Integer? value) → Integer?
Source
# File lib/serega/config.rb, line 187 def depth_limit=(value) valid = value.nil? || (value.is_a?(Integer) && value.positive?) raise SeregaError, "Must have positive Integer or nil value, #{value.inspect} provided" unless valid opts[:depth_limit] = value end
Sets depth_limit: a positive Integer or nil
Source
# File lib/serega/config.rb, line 164 def hash_access @hash_access ||= HashAccessConfig.new(opts.fetch(:hash_access)) end
Defaults of the hash_access: attribute option
() → (bool | :auto)
Source
# File lib/serega/config.rb, line 119 def hide_by_default opts.fetch(:hide_by_default) end
Which attributes are hidden without the :hide option: false for none (the default), true for all, :auto for attributes with preloads or batch loaders.
(bool | :auto value) → (bool | :auto)
Source
# File lib/serega/config.rb, line 124 def hide_by_default=(value) opts[:hide_by_default] = case value when true, false, :auto value else raise SeregaError, "Must have true, false, or :auto, #{value.inspect} provided" end end
Sets hide_by_default
() → Integer
Source
# File lib/serega/config.rb, line 170 def max_cached_plans_per_serializer_count opts.fetch(:max_cached_plans_per_serializer_count) end
How many serialization plans with field selection the serializer caches, 20 by default. 0 disables the cache.
(Integer value) → Integer
Source
# File lib/serega/config.rb, line 175 def max_cached_plans_per_serializer_count=(value) raise SeregaError, "Must have Integer value, #{value.inspect} provided" unless value.is_a?(Integer) opts[:max_cached_plans_per_serializer_count] = value end
() → bool
Source
# File lib/serega/config.rb, line 206 def require_many opts.fetch(:require_many) end
Whether every relation, an attribute with :serializer or a block, must have the :many option. false by default.
(bool value) → bool
Source
# File lib/serega/config.rb, line 211 def require_many=(value) opts[:require_many] = checked_boolean(value) end
Sets require_many