Sha256: 8e405c9f9d799a4f7cce00173c793aceb75e085f1f4efb7a9184183849554dc7

Contents?: true

Size: 857 Bytes

Versions: 125

Compression:

Stored size: 857 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

125 entries across 125 versions & 1 rubygems

Version Path
trusty-cms-4.1.2 app/models/status.rb
trusty-cms-4.1.1 app/models/status.rb
trusty-cms-4.1.0 app/models/status.rb
trusty-cms-4.0.2 app/models/status.rb
trusty-cms-3.9.7 app/models/status.rb
trusty-cms-3.9.6 app/models/status.rb
trusty-cms-3.9.5 app/models/status.rb
trusty-cms-4.0.1 app/models/status.rb
trusty-cms-3.9.4 app/models/status.rb
trusty-cms-3.9.3 app/models/status.rb
trusty-cms-3.9.2 app/models/status.rb
trusty-cms-4.0.0 app/models/status.rb
trusty-cms-3.9.1 app/models/status.rb
trusty-cms-3.9.0 app/models/status.rb
trusty-cms-3.8.4 app/models/status.rb
trusty-cms-3.8.3 app/models/status.rb
trusty-cms-3.8.2 app/models/status.rb
trusty-cms-3.8.1 app/models/status.rb
trusty-cms-3.8.0 app/models/status.rb
trusty-cms-3.7.1 app/models/status.rb