Class: Banner
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Banner
- Defined in:
- app/models/banner.rb
Instance Attribute Summary collapse
Class Method Summary collapse
- .find_active ⇒ Object
- .find_active_by_pages ⇒ Object
- .find_all_by_pages ⇒ Object
- .find_inactive ⇒ Object
- .total_active_count ⇒ Object
- .total_count ⇒ Object
- .total_inactive_count ⇒ Object
Instance Method Summary collapse
- #active? ⇒ Boolean
- #inactive? ⇒ Boolean
- #protected? ⇒ Boolean
- #remove_all_placements! ⇒ Object
- #unprotected? ⇒ Boolean
Instance Attribute Details
#placements ⇒ Object
23 24 25 |
# File 'app/models/banner.rb', line 23 def placements @placements || end |
Class Method Details
.find_active ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/models/banner.rb', line 55 def self.find_active @banners = [] self.find(:all, :order => "name asc").each do || @banners << if .active? end @banners end |
.find_active_by_pages ⇒ Object
63 64 65 |
# File 'app/models/banner.rb', line 63 def self.find_active_by_pages self.find_active.sort { |a,b| a.pages[0]. <=> b.pages[0]. } end |
.find_all_by_pages ⇒ Object
51 52 53 |
# File 'app/models/banner.rb', line 51 def self.find_all_by_pages self.find_active_by_pages.concat(self.find_inactive) end |
.find_inactive ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/models/banner.rb', line 67 def self.find_inactive @banners = [] self.find(:all, :order => "name asc").each do || @banners << if .inactive? end @banners end |
.total_active_count ⇒ Object
79 80 81 |
# File 'app/models/banner.rb', line 79 def self.total_active_count self.find_active.size end |
.total_count ⇒ Object
75 76 77 |
# File 'app/models/banner.rb', line 75 def self.total_count self.find(:all).size end |
.total_inactive_count ⇒ Object
83 84 85 |
# File 'app/models/banner.rb', line 83 def self.total_inactive_count self.find_inactive.size end |
Instance Method Details
#active? ⇒ Boolean
27 28 29 |
# File 'app/models/banner.rb', line 27 def active? .size > 0 end |
#inactive? ⇒ Boolean
31 32 33 |
# File 'app/models/banner.rb', line 31 def inactive? ! active? end |
#protected? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/banner.rb', line 35 def protected? if name.downcase.include?('protected') true else = [] if Radiant::Config['admin.protected_banners'] = Radiant::Config['admin.protected_banners'].split(',').map { |b| b.downcase.strip } end .include?(name.downcase) end end |
#remove_all_placements! ⇒ Object
87 88 89 |
# File 'app/models/banner.rb', line 87 def remove_all_placements! .each { |placement| placement.destroy } end |
#unprotected? ⇒ Boolean
47 48 49 |
# File 'app/models/banner.rb', line 47 def unprotected? ! protected? end |