lib/yandex/metrika.rb in yandex_metrika-0.0.0 vs lib/yandex/metrika.rb in yandex_metrika-0.0.1
- old
+ new
@@ -6,26 +6,32 @@
class Metrika
# This module gets mixed in to ActionController::Base
module Mixin
# The javascript code to enable Yandex.Metrika on the current page.
- # Normally you won't need to call this directly; the +add_metrika_code+
+ # Normally you won't need to call this directly; the +add_yandex_metrika_code+
# after filter will insert it for you.
def metrika_code
Metrika.code if Metrika.enabled?(request.format)
end
# An after_filter to automatically add the metrika code.
- def add_metrika_code
+ def add_yandex_metrika_code
if Metrika.defer_load
response.body.sub! /<\/[bB][oO][dD][yY]>/, "#{metrika_code}</body>" if response.body.respond_to?(:sub!)
else
response.body.sub! /(<[bB][oO][dD][yY][^>]*>)/, "\\1#{metrika_code}" if response.body.respond_to?(:sub!)
end
end
end
- class ConfigurationError < StandardError; end
+ class ConfigurationError < StandardError #:nodoc:
+ DEFAULT_MESSAGE = "Yandex::Metrika.counter_id is not set in config/environment.rb or config/initializers/yandex_metrika.rb"
+
+ def initialize(message = nil)
+ super(message || DEFAULT_MESSAGE)
+ end
+ end
@@counter_id = nil
##
# :singleton-method:
# Specify the Yandex.Metrika COUNTER_ID for this web site. This can be found