Sha256: c32e1dc4db38dc171d9b9f1a4c688471e766d97b454fcda2c4c22271bd18c569

Contents?: true

Size: 839 Bytes

Versions: 3

Compression:

Stored size: 839 Bytes

Contents

class SpudBannerSet < ActiveRecord::Base
  attr_accessible :cropped, :height, :name, :short_name, :width, :has_rich_text
  has_many :banners, :class_name => 'SpudBanner', :order => 'sort_order asc', :dependent => :destroy, :inverse_of => :owner

  validates_presence_of :name
  validates_uniqueness_of :name
  validates_numericality_of :width, :height

  def self.find_by_identifier(identifier)
    if identifier.class == String
      banner_set = SpudBannerSet.find_by_name(identifier)
    elsif identifier.class == Symbol
      banner_set = SpudBannerSet.find_by_name(identifier.to_s.titleize)
    else
      banner_set = SpudBannerSet.find(identifier)
    end
    return banner_set
  end

  def reprocess_banners!
    self.banners.each do |banner|
      banner.banner.reprocess!
    end
  end

  def set_name
    return name
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tb_banners-1.0.2 app/models/spud_banner_set.rb
tb_banners-1.0.1 app/models/spud_banner_set.rb
tb_banners-1.0 app/models/spud_banner_set.rb