Sha256: 540250f11d2de1aeaa91b0879688733f3870c64eb74ca7bd1caf88f31065a3b2

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

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

  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

4 entries across 4 versions & 1 rubygems

Version Path
spud_banners-0.9.0.2 app/models/spud_banner_set.rb
spud_banners-0.9.0.1 app/models/spud_banner_set.rb
spud_banners-0.9.0 app/models/spud_banner_set.rb
spud_banners-0.0.1 app/models/spud_banner_set.rb