Module: LazyRecord::BaseModule::ClassMethods

Defined in:
lib/lazy_record/base_module.rb

Overview

Class methods provided to all LazyRecord classes

Instance Method Summary collapse

Instance Method Details

#allObject



72
73
74
# File 'lib/lazy_record/base_module.rb', line 72

def all
  @all ||= Relation.new(model: self)
end

#countObject



76
77
78
# File 'lib/lazy_record/base_module.rb', line 76

def count
  all.count
end

#destroy_allObject



92
93
94
# File 'lib/lazy_record/base_module.rb', line 92

def destroy_all
  all.send(:clear)
end

#firstObject



80
81
82
# File 'lib/lazy_record/base_module.rb', line 80

def first
  all.first
end

#lastObject



84
85
86
# File 'lib/lazy_record/base_module.rb', line 84

def last
  all.last
end

#where(condition = nil, &block) ⇒ Object



88
89
90
# File 'lib/lazy_record/base_module.rb', line 88

def where(condition = nil, &block)
  all.where(condition, &block)
end