Sha256: 4ae51647038c40a4730df70ffe6d5a290924b8c5eaa6b6e5473c5a08b793ddb4

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Ads
  module Rails
    module ActionView
      module Base

        def google_adsense_include_tag(*args)
          options = args.extract_options!
          if ['production','test'].include? ::Rails.env
            script = <<-SCRIPT
              google_ad_client = '#{options[:client]}';
              google_ad_slot = '#{options[:slot]}'; 
              google_ad_width = #{options[:width]};
              google_ad_height = #{options[:height]};
            SCRIPT
            content_tag(:script, script.html_safe, type: 'text/javascript') +
            content_tag(:script, nil, type: 'text/javascript', src: 'http://pagead2.googlesyndication.com/pagead/show_ads.js')
          elsif ::Rails.env.development?
            if ::Rails.application.config.ads.renderer.is_a? Proc
              instance_exec(options, &::Rails.application.config.ads.renderer)
            else
              content_tag(:div, nil, style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;")
            end
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ads-rails-0.0.5 lib/ads/rails/action_view/base.rb
ads-rails-0.0.4 lib/ads/rails/action_view/base.rb