Sha256: ce676fe39913e22702312bbf60d7e3de63c60f3549d6590d946516821ce8fb32

Contents?: true

Size: 684 Bytes

Versions: 27

Compression:

Stored size: 684 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
  
  @@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'   )
  ]
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 app/models/status.rb
radiantcms-couchrest_model-0.2.2 app/models/status.rb
radiantcms-couchrest_model-0.2.1 app/models/status.rb
radiantcms-couchrest_model-0.2 app/models/status.rb
radiantcms-couchrest_model-0.1.9 app/models/status.rb
radiantcms-couchrest_model-0.1.8 app/models/status.rb
radiantcms-couchrest_model-0.1.7 app/models/status.rb
radiantcms-couchrest_model-0.1.6 app/models/status.rb
radiantcms-couchrest_model-0.1.5 app/models/status.rb
radiant-0.7.2 app/models/status.rb
radiant-0.8.2 app/models/status.rb
radiant-rc-0.9.0 app/models/status.rb
radiant-0.8.1 app/models/status.rb
radiant-0.6.1 app/models/status.rb
radiant-0.6.0 app/models/status.rb
radiant-0.6.3 app/models/status.rb
radiant-0.6.2 app/models/status.rb
radiant-0.6.5.1 app/models/status.rb
radiant-0.6.4 app/models/status.rb
radiant-0.6.5 app/models/status.rb