Sha256: 6208fa2a079d26a67ff31a7ff341958ce107c4034de11134e2f75e896d8b18f4

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module Ads
  module Rails
    module ActionView
      module Base

        def google_adsense_include_tag(*args)
          options = args.extract_options!
          if ::Rails.env.production?
            script = ''.tap do |script|
              options.each do |key, value|
                if value.is_a? String
                  value = "'#{value}'"
                end
                script << "google_ad_#{key} = #{value};\n"
              end
            end
            content_tag(
              :script,
              script.html_safe,
              type: 'text/javascript'
            ) +
            content_tag(
              :script,
              nil,
              type: 'text/javascript',
              src: "#{request.protocol}pagead2.googlesyndication.com/pagead/show_ads.js"
            )
          elsif Ads.config.renderer.is_a? Proc
            instance_exec options, &Ads.config.renderer
          else
            content_tag(
              :div,
              nil,
              style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;"
            )
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ads-rails-0.2.1 lib/ads/rails/action_view/base.rb
ads-rails-0.2.0 lib/ads/rails/action_view/base.rb