module Sequel::Plugins::ForbidLazyLoad::InstanceMethods
Public Instance Methods
Source
# File lib/sequel/plugins/forbid_lazy_load.rb 148 def allow_lazy_load 149 @forbid_lazy_load = false 150 self 151 end
Set this model instance to allow lazy loading of associations.
Source
# File lib/sequel/plugins/forbid_lazy_load.rb 154 def forbid_lazy_load 155 @forbid_lazy_load = true 156 self 157 end
Set this model instance to not allow lazy loading of associations.
Private Instance Methods
Source
# File lib/sequel/plugins/forbid_lazy_load.rb 162 def _load_associated_object(opts, dynamic_opts) 163 # The implementation that loads these associations does 164 # .all.first, which would result in the object returned being 165 # marked as forbidding lazy load. 166 obj = super 167 obj.allow_lazy_load if obj.is_a?(InstanceMethods) 168 obj 169 end
Allow lazy loading for objects returned by singular associations.
Calls superclass method
Source
# File lib/sequel/plugins/forbid_lazy_load.rb 173 def _load_associated_objects(opts, dynamic_opts=OPTS) 174 case dynamic_opts[:forbid_lazy_load] 175 when false 176 # nothing 177 when nil 178 unless dynamic_opts[:reload] 179 case opts[:forbid_lazy_load] 180 when nil 181 raise Error, "lazy loading forbidden for this object (association: #{opts.inspect}, object: #{inspect})" if @forbid_lazy_load 182 when false 183 # nothing 184 else 185 raise Error, "lazy loading forbidden for this association (#{opts.inspect})" 186 end 187 end 188 else 189 raise Error, "lazy loading forbidden for this association method call (association: #{opts.inspect})" 190 end 191 192 super 193 end
Raise an Error if lazy loading has been forbidden for the instance, association, or call.
Calls superclass method