45 lines
991 B
Ruby
45 lines
991 B
Ruby
module OrbitModel
|
|
|
|
module Status
|
|
|
|
def self.included(base)
|
|
base.extend ClassMethods
|
|
base.class_eval do
|
|
field :is_top, :type => Boolean, :default => false
|
|
field :is_hot, :type => Boolean, :default => false
|
|
field :is_hidden, :type => Boolean, :default => false
|
|
self.class_variable_defined?(:@@can_display) ? \
|
|
self.class_variable_set(:@@can_display, self.class_variable_get(:@@can_display).merge({is_hidden: false})) : \
|
|
self.class_variable_set(:@@can_display, {is_hidden: false})
|
|
send :include, InstanceMethods
|
|
end
|
|
end
|
|
|
|
module InstanceMethods
|
|
|
|
def is_top?
|
|
self.is_top
|
|
end
|
|
|
|
def is_hot?
|
|
self.is_hot
|
|
end
|
|
|
|
def is_hidden?
|
|
self.is_hidden
|
|
end
|
|
|
|
end
|
|
|
|
module ClassMethods
|
|
|
|
define_method(:can_display) do
|
|
where(class_variable_get(:@@can_display))
|
|
end unless method_defined? :can_display
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|