Module: Serega::SeregaPlugins::Preloads
- Defined in:
- lib/serega/plugins/preloads/preloads.rb,
lib/serega/plugins/preloads/lib/enum_deep_freeze.rb,
lib/serega/plugins/preloads/lib/main_preload_path.rb,
lib/serega/plugins/preloads/lib/format_user_preloads.rb,
lib/serega/plugins/preloads/lib/preloads_constructor.rb,
lib/serega/plugins/preloads/validations/check_opt_preload.rb,
lib/serega/plugins/preloads/validations/check_opt_preload_path.rb
Overview
Plugin adds `.preloads` method to find relations that must be preloaded
Defined Under Namespace
Modules: AttributeMethods, CheckAttributeParamsInstanceMethods, ConfigInstanceMethods, InstanceMethods Classes: CheckOptPreload, CheckOptPreloadPath, EnumDeepFreeze, FormatUserPreloads, MainPreloadPath, PreloadsConfig, PreloadsConstructor
Constant Summary collapse
- DEFAULT_CONFIG =
{ auto_preload_attributes_with_delegate: false, auto_preload_attributes_with_serializer: false, auto_hide_attributes_with_preload: false }.freeze
Class Method Summary collapse
- .after_load_plugin(serializer_class, **opts) ⇒ Object
-
.load_plugin(serializer_class, **_opts) ⇒ void
Includes plugin modules to current serializer.
-
.plugin_name ⇒ Symbol
Plugin name.
Class Method Details
.after_load_plugin(serializer_class, **opts) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/serega/plugins/preloads/preloads.rb', line 43 def self.after_load_plugin(serializer_class, **opts) config = serializer_class.config config.attribute_keys << :preload << :preload_path preloads_opts = DEFAULT_CONFIG.merge(opts.slice(*DEFAULT_CONFIG.keys)) config.opts[:preloads] = {} preloads_config = config.preloads preloads_config.auto_preload_attributes_with_delegate = preloads_opts[:auto_preload_attributes_with_delegate] preloads_config.auto_preload_attributes_with_serializer = preloads_opts[:auto_preload_attributes_with_serializer] preloads_config.auto_hide_attributes_with_preload = preloads_opts[:auto_hide_attributes_with_preload] end |
.load_plugin(serializer_class, **_opts) ⇒ void
This method returns an undefined value.
Includes plugin modules to current serializer
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/serega/plugins/preloads/preloads.rb', line 28 def self.load_plugin(serializer_class, **_opts) serializer_class.include(InstanceMethods) serializer_class::SeregaAttribute.include(AttributeMethods) serializer_class::SeregaConfig.include(ConfigInstanceMethods) serializer_class::CheckAttributeParams.include(CheckAttributeParamsInstanceMethods) require_relative "./lib/enum_deep_freeze" require_relative "./lib/format_user_preloads" require_relative "./lib/main_preload_path" require_relative "./lib/preloads_constructor" require_relative "./validations/check_opt_preload" require_relative "./validations/check_opt_preload_path" end |
.plugin_name ⇒ Symbol
Returns plugin name.
16 17 18 |
# File 'lib/serega/plugins/preloads/preloads.rb', line 16 def self.plugin_name :preloads end |