Method: ArAdRenderer#default

Defined in:
app/renderers/ar_ad_renderer.rb

#defaultObject

Default method for rendering ads.



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'app/renderers/ar_ad_renderer.rb', line 174

def default
  return '' if @env.session[:is_robot] # don't bother if robot
  html = ''
  if (ad = find_ad_to_display)
# save to statistics, if not in cms
    if @opts[:edit_mode] < 1
      ArAdStat.create!(ar_ad_id: ad.id, ip: @env.request.ip, type: 1 )
# save display counter  
      ad.displayed += 1
      ad.save
    end
    html += case ad.type
    when 1 then # picture
      picture_ad ad
    when 2 then # flash
      flash_ad ad
    when 3 then # script
      ad.script
    else
      'Error. Wrong ad type!'
    end
  end
  html
end