Sha256: 93fb67673d10b4ed85813ab65037addc188456b337175d8bf8268e95a4e37f30

Contents?: true

Size: 875 Bytes

Versions: 21

Compression:

Stored size: 875 Bytes

Contents

class Status
  attr_accessor :id, :name

  def initialize(options = {})
    options = options.symbolize_keys
    @id, @name = options[:id], 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.find_all
    @@statuses.dup
  end
  
  def self.selectable
    find_all - [self['Scheduled']]
  end
    
  def self.selectable_values
    self.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

21 entries across 21 versions & 4 rubygems

Version Path
trusty-cms-1.0.0 app/models/status.rb
radiant-1.1.4 app/models/status.rb
radiant-1.1.3 app/models/status.rb
radiant-1.1.2 app/models/status.rb
radiant-1.1.1 app/models/status.rb
radiant-1.1.0 app/models/status.rb
radiant-1.1.0.rc1 app/models/status.rb
radiant-1.1.0.beta app/models/status.rb
radiant-1.0.1 app/models/status.rb
radiant-1.1.0.alpha app/models/status.rb
radiant-1.0.0 app/models/status.rb
radiant-1.0.0.rc5 app/models/status.rb
radiant-1.0.0.rc4 app/models/status.rb
radiant-1.0.0.rc3 app/models/status.rb
kajam-1.0.3.rc2 app/models/status.rb
radiant-1.0.0.rc2 app/models/status.rb
radiant-1.0.0.rc1 app/models/status.rb
radiantcms-couchrest_model-0.1.3 app/models/status.rb
radiantcms-couchrest_model-0.1.2 app/models/status.rb
radiantcms-couchrest_model-0.1.1 app/models/status.rb