Class: Status

Inherits:
Object show all
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 => 100, :name => 'Published'),
  Status.new(:id => 101, :name => 'Hidden'   )
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Status

Returns a new instance of Status.



4
5
6
7
# File 'app/models/status.rb', line 4

def initialize(options = {})
  options = options.symbolize_keys
  @id, @name = options[:id], options[:name]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



2
3
4
# File 'app/models/status.rb', line 2

def id
  @id
end

#nameObject

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_allObject



21
22
23
# File 'app/models/status.rb', line 21

def self.find_all
  @@statuses.dup
end

Instance Method Details

#symbolObject



9
10
11
# File 'app/models/status.rb', line 9

def symbol
  @name.to_s.downcase.intern
end