module OrbitModel
module Status
def self.included(base)
base.extend ClassMethods
base.field :is_top, :type => Boolean, :default => false
base.field :is_hot, :type => Boolean, :default => false
base.field :is_hidden, :type => Boolean, :default => false
def is_top?
self.is_top
end
def is_hot?
self.is_hot
end
def is_hidden?
self.is_hidden
end
def status_for_table
status = ""
status << "#{I18n.t(:top)} " if self.is_top
status << "#{I18n.t(:hot)} " if self.is_hot
status << "#{I18n.t(:hidden)}"if self.is_hidden
status.html_safe
end
end
module ClassMethods
def with_status(status)
status = [status].flatten
self.any_of(status.map{|s| {s.to_sym=>true}})
end
end
end
end