module GreyscaleRecord::Queriable

Public Class Methods

all() click to toggle source
# File lib/greyscale_record/queriable.rb, line 19
def all
  where.all
end
find(id) click to toggle source
# File lib/greyscale_record/queriable.rb, line 7
def find(id)
  records = where( id: id.to_s )
  raise Errors::RecordNotFound, "#{ self }: Record not found: #{ id }" if records.empty?
  records.first
end
find_by( params = { } ) click to toggle source
# File lib/greyscale_record/queriable.rb, line 13
def find_by( params = { } )
  results = where params
  raise Errors::RecordNotFound, "#{ self }: Could not find record that matches: #{ params.inspect }" if results.empty?
  results.first
end
first() click to toggle source
# File lib/greyscale_record/queriable.rb, line 23
def first
  all.first
end
where( params = {} ) click to toggle source
# File lib/greyscale_record/queriable.rb, line 27
def where( params = {} )
  Relation.new self, params 
end