root/trunk/radiant/app/models/status.rb

Revision 405, 0.7 kB (checked in by jlong, 1 year ago)

merged changes from the mental branch into trunk r125:404

Line 
1 class Status
2   attr_accessor :id, :name
3
4   def initialize(options = {})
5     options = options.symbolize_keys
6     @id, @name = options[:id], options[:name]
7   end
8  
9   def symbol
10     @name.to_s.downcase.intern
11   end
12  
13   def self.[](value)
14     @@statuses.find { |status| status.symbol == value.to_s.downcase.intern }
15   end
16  
17   def self.find(id)
18     @@statuses.find { |status| status.id.to_s == id.to_s }
19   end
20  
21   def self.find_all
22     @@statuses.dup
23   end
24  
25   @@statuses = [
26     Status.new(:id => 1,   :name => 'Draft'    ),
27     Status.new(:id => 50,  :name => 'Reviewed' ),
28     Status.new(:id => 100, :name => 'Published'),
29     Status.new(:id => 101, :name => 'Hidden'   )
30   ]
31 end
Note: See TracBrowser for help on using the browser.