Class: Status
- Inherits:
-
Object
- Object
- Status
- Defined in:
- app/models/status.rb
Constant Summary collapse
- @@statuses =
[ Status.new(id: 1, name: 'Draft'), Status.new(id: 50, name: 'Reviewed'), Status.new(id: 90, name: 'Scheduled'), 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
- .[](value) ⇒ Object
- .find(id) ⇒ Object
- .find_all ⇒ Object
- .selectable ⇒ Object
- .selectable_values ⇒ Object
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 8 |
# File 'app/models/status.rb', line 4 def initialize( = {}) = .symbolize_keys @id = [:id] @name = [: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
14 15 16 |
# File 'app/models/status.rb', line 14 def self.[](value) @@statuses.find { |status| status.symbol == value.to_s.downcase.intern } end |
.find(id) ⇒ Object
18 19 20 |
# File 'app/models/status.rb', line 18 def self.find(id) @@statuses.find { |status| status.id.to_s == id.to_s } end |
.find_all ⇒ Object
22 23 24 |
# File 'app/models/status.rb', line 22 def self.find_all @@statuses.dup end |
.selectable ⇒ Object
26 27 28 |
# File 'app/models/status.rb', line 26 def self.selectable find_all - [self['Scheduled']] end |
.selectable_values ⇒ Object
30 31 32 |
# File 'app/models/status.rb', line 30 def self.selectable_values selectable.map(&:name) end |
Instance Method Details
#symbol ⇒ Object
10 11 12 |
# File 'app/models/status.rb', line 10 def symbol @name.to_s.downcase.intern end |