Module: Sequel::Plugins::ForbidLazyLoad::ForbidByDefault

Defined in:
lib/sequel/plugins/forbid_lazy_load.rb

Instance Method Summary collapse

Instance Method Details

#eachObject

Mark model instances retrieved in this call as forbidding lazy loading.



197
198
199
200
201
202
203
204
205
206
# File 'lib/sequel/plugins/forbid_lazy_load.rb', line 197

def each
  if row_proc
    super do |obj|
      obj.forbid_lazy_load if obj.is_a?(InstanceMethods)
      yield obj
    end
  else
    super
  end
end

#with_sql_each(sql) ⇒ Object

Mark model instances retrieved in this call as forbidding lazy loading.



209
210
211
212
213
214
215
216
217
218
# File 'lib/sequel/plugins/forbid_lazy_load.rb', line 209

def with_sql_each(sql)
  if row_proc
    super(sql) do |obj|
      obj.forbid_lazy_load if obj.is_a?(InstanceMethods)
      yield obj
    end
  else
    super
  end
end

#with_sql_first(sql) ⇒ Object

Mark model instances retrieved in this call as allowing lazy loading.



221
222
223
224
225
# File 'lib/sequel/plugins/forbid_lazy_load.rb', line 221

def with_sql_first(sql)
  obj = super
  obj.allow_lazy_load if obj.is_a?(InstanceMethods)
  obj
end