Skip to content

Instantly share code, notes, and snippets.

@jccarbonfive
Created December 17, 2012 01:11
Show Gist options
  • Save jccarbonfive/4314996 to your computer and use it in GitHub Desktop.
Save jccarbonfive/4314996 to your computer and use it in GitHub Desktop.
class Loan < ActiveRecord::Base
def self.pending
where state: 'pending'
end
def self.delinquent
where('expires_on < ?', Time.zone.today)
.where('repaid = ?', false)
end
end
module Lender
def self.pending
Loan
.where state: 'pending'
end
def self.delinquent
Loan
.where('expires_on < ?', Time.zone.today)
.where('repaid = ?', false)
end
end
class Account < ActiveRecord::Base
def self.overdrawn
where 'balance < ?', 0
end
end
module Bank
def self.overdrawn
Account
.where 'balance < ?', 0
end
end
class PhoneCall < ActiveRecord::Base
def self.since(date)
where 'created_at > ?', date
end
end
module TelephonyProvider
def self.call_history_since(date)
PhoneCall
.where 'created_at > ?', date
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment