Sha256: 5979e86469e44826eab5b4cd60b57a72972d816980ee9a94808318a2c372a7df

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 Bytes

Contents

class Status
  attr_accessor :id, :name

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

  def symbol
    @name.to_s.downcase.intern
  end

  def self.[](value)
    @@statuses.find { |status| status.symbol == value.to_s.downcase.intern }
  end

  def self.find(id)
    @@statuses.find { |status| status.id.to_s == id.to_s }
  end

  def self.selectable
    @@statuses
  end

  def self.selectable_values
    selectable.map(&:name)
  end

  @@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'),
  ]
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trusty-cms-7.0.8 app/models/status.rb
trusty-cms-7.0.7 app/models/status.rb
trusty-cms-7.0.6 app/models/status.rb
trusty-cms-7.0.5 app/models/status.rb
trusty-cms-7.0.4 app/models/status.rb