Module: AmsLazyRelationships::Core
- Defined in:
- lib/ams_lazy_relationships/core.rb,
lib/ams_lazy_relationships/core/evaluation.rb,
lib/ams_lazy_relationships/core/lazy_dig_method.rb,
lib/ams_lazy_relationships/core/lazy_relationship_meta.rb,
lib/ams_lazy_relationships/core/lazy_relationship_method.rb,
lib/ams_lazy_relationships/core/relationship_wrapper_methods.rb
Overview
This module defines a set of methods useful for eliminating N+1 query problem during the serialization. Serializers will first prepare a tree of “promises” for every nested lazy relationship. The relationship promises will be evaluated only when they’re requested. E.g. when including ‘comments.user`: instead of loading a user for each comment separately it’ll gather the comments and load all their users at once when including the users in the response.
Defined Under Namespace
Modules: ClassMethods, Evaluation, Initializer, LazyDigMethod, LazyRelationshipMethod, RelationshipWrapperMethods Classes: LazyRelationshipMeta
Class Method Summary collapse
Class Method Details
.ams_version ⇒ Object
16 17 18 |
# File 'lib/ams_lazy_relationships/core.rb', line 16 def self.ams_version @_ams_version ||= Gem::Version.new(ActiveModel::Serializer::VERSION) end |
.included(klass) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ams_lazy_relationships/core.rb', line 20 def self.included(klass) klass.send :extend, ClassMethods klass.send :include, LazyDigMethod klass.send :prepend, Initializer klass.send(:define_relationship_wrapper_methods) end |