Module: Sequel::Plugins::ForbidLazyLoad::DatasetMethods

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.


184
185
186
187
188
189
190
191
192
193
# File 'lib/sequel/plugins/forbid_lazy_load.rb', line 184

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.


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

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.


208
209
210
211
212
# File 'lib/sequel/plugins/forbid_lazy_load.rb', line 208

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