Orbit/app/models/ad_banner.rb

31 lines
774 B
Ruby

class AdBanner
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include OrbitTag::Taggable
include OrbitModel::Authorizable
field :ad_fx #TODO Design should explain
field :height, type: Integer
field :speed, type: Integer
field :title
field :timeout, type: Integer
field :width, type: Integer
has_many :ad_images , dependent: :delete
validates_uniqueness_of :title
validates :title, :length => { :minimum => 2 }
validates :height, :speed, :timeout, :width, :presence => true
FX_TYPES = %w(fade fadeout flipHorz flipVert scrollHorz scrollVert tileSlide tileBlind)
def size
"#{self.width} x #{self.height}"
end
def timeout_millisecond
self.timeout*1000 rescue 0
end
end