9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/helpers/effective_banner_ads_helper.rb', line 9
def render_banner_ad(location, opts = {}, &block)
location = EffectivePages.banner_ads.find { |obj| obj == location }
raise("unknown banner ad location: #{location.presence || 'nil'}. Please add it to EffectivePages.banner_ads config option") if location.blank?
banner_ads = effective_banner_ads.select { |ba| ba.location == location }
return if banner_ads.blank?
banner_ad = banner_ads.sample
if block_given?
yield(banner_ad); nil
else
render('effective/banner_ads/banner_ad', banner_ad: banner_ad, banner_ad_opts: opts)
end
end
|