Module: LazyRecord::ClassMethods

Defined in:
lib/lazy_record/class_methods.rb

Overview

Class methods extended to all LazyRecord descendants.

Instance Method Summary collapse

Instance Method Details

#allObject



16
17
18
# File 'lib/lazy_record/class_methods.rb', line 16

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

#attr_readersObject



12
13
14
# File 'lib/lazy_record/class_methods.rb', line 12

def attr_readers
  @attr_readers ||= []
end

#countObject



20
21
22
# File 'lib/lazy_record/class_methods.rb', line 20

def count
  all.count
end

#destroy_allObject



36
37
38
# File 'lib/lazy_record/class_methods.rb', line 36

def destroy_all
  all.send(:clear)
end

#firstObject



24
25
26
# File 'lib/lazy_record/class_methods.rb', line 24

def first
  all.first
end

#lastObject



28
29
30
# File 'lib/lazy_record/class_methods.rb', line 28

def last
  all.last
end

#public_attr_readersObject



6
7
8
9
10
# File 'lib/lazy_record/class_methods.rb', line 6

def public_attr_readers
  @public_attr_readers ||= attr_readers.reject do |reader|
    private_method_defined?(reader) || protected_method_defined?(reader)
  end
end

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



32
33
34
# File 'lib/lazy_record/class_methods.rb', line 32

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