orbit-basic/app/models/ad_banner.rb

31 lines
964 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 = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"]
def size
"#{self.width} x #{self.height}"
end
def timeout_in_min
self.timeout*1000 rescue 0
end
end