Class: Category

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/category.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.expensesObject



28
29
30
# File 'app/models/category.rb', line 28

def self.expenses
  self.all(:conditions => {:kind => "Expense"})
end

.hashedObject



15
16
17
18
19
20
21
22
# File 'app/models/category.rb', line 15

def self.hashed
  {
    :income =>
    self.all(:conditions => {:kind => "Income"},  :order => "position"),
    :expense =>
    self.all(:conditions => {:kind => "Expense"}, :order => "position"),
  }
end

.incomesObject



24
25
26
# File 'app/models/category.rb', line 24

def self.incomes
  self.all(:conditions => {:kind => "Income"})
end

Instance Method Details

#validateObject



5
6
7
8
9
# File 'app/models/category.rb', line 5

def validate
  unless %w(Income Expense).include?(self.kind)
    errors.add("kind", "#{self.kind.inspect} must be either of Income or Expense")
  end
end