Class: Status
Constant Summary collapse
- @@statuses =
[ Status.new(:id => 1, :name => 'Draft' ), Status.new(:id => 50, :name => 'Reviewed' ), Status.new(:id => 100, :name => 'Published'), Status.new(:id => 101, :name => 'Hidden' ) ]
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Status
constructor
A new instance of Status.
- #symbol ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Status
Returns a new instance of Status.
4 5 6 7 |
# File 'app/models/status.rb', line 4 def initialize( = {}) = .symbolize_keys @id, @name = [:id], [:name] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'app/models/status.rb', line 2 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'app/models/status.rb', line 2 def name @name end |
Class Method Details
.[](value) ⇒ Object
13 14 15 |
# File 'app/models/status.rb', line 13 def self.[](value) @@statuses.find { |status| status.symbol == value.to_s.downcase.intern } end |
.find(id) ⇒ Object
17 18 19 |
# File 'app/models/status.rb', line 17 def self.find(id) @@statuses.find { |status| status.id.to_s == id.to_s } end |
.find_all ⇒ Object
21 22 23 |
# File 'app/models/status.rb', line 21 def self.find_all @@statuses.dup end |
Instance Method Details
#symbol ⇒ Object
9 10 11 |
# File 'app/models/status.rb', line 9 def symbol @name.to_s.downcase.intern end |