module Preloadable::ClassMethods
Public Instance Methods
preloadable(&block)
click to toggle source
# File lib/jsonapi-preloadable.rb, line 42 def preloadable(&block) block.call(preloadable_config) end
preloadable_config()
click to toggle source
# File lib/jsonapi-preloadable.rb, line 38 def preloadable_config @preloadable_config ||= PreloadableAttributeConfig.new end
records(options = {})
click to toggle source
Calls superclass method
# File lib/jsonapi-preloadable.rb, line 46 def records(options = {}) attrs = preloadable_config.defaults.dup context_args = options.dig(:context, :preload) if context_args.present? attrs.merge(context_args.split(",").map(&:to_sym)) end return super if attrs.empty? includable = preloadable_config.attrs.map do |key, value| value if attrs.include?(key) end.compact super.includes(includable) end