module AmsLazyRelationships::Core

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.

Public Class Methods

ams_version() click to toggle source
# File lib/ams_lazy_relationships/core.rb, line 16
def self.ams_version
  @_ams_version ||= Gem::Version.new(ActiveModel::Serializer::VERSION)
end
included(klass) click to toggle source
# 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