Permalink
Browse files

Allow fallback to BasicReporter

  • Loading branch information...
1 parent 920d53b commit 76dd47114952fca0d53f2eec905c06a79b97ab62 @randland randland committed Jun 2, 2011
Showing with 20 additions and 22 deletions.
  1. +12 −12 lib/omniture_client/base.rb
  2. +8 −10 lib/omniture_rails.rb
@@ -1,29 +1,29 @@
module OmnitureClient
class Base
-
+
DEFAULT_OPTIONS = { :delimiter => ',',
:unique => nil,
:expires_in => 0 }
-
+
class << self
attr_reader :meta_vars, :js_events
@@controller = nil
-
+
def var(name, options={}, &block)
options = DEFAULT_OPTIONS.merge(options)
-
+
@meta_vars ||= []
meta_var = instance_eval("@#{name} ||= OmnitureClient::MetaVar.new('#{name}', '#{options[:delimiter]}', '#{options[:unique]}', #{options[:expires_in]})")
meta_var.add_var(block)
meta_vars << meta_var unless meta_vars.include?(meta_var)
meta_var
end
-
- def event(&block)
+
+ def event(&block)
@js_events ||= []
@js_events << yield
end
-
+
def clear_meta_vars
if @meta_vars.present?
@meta_vars.each do |var|
@@ -32,14 +32,14 @@ def clear_meta_vars
@meta_vars = []
end
end
-
+
def for_action(name, &block)
RAILS_DEFAULT_LOGGER.info("name = #{name}")
yield
end
-
+
end
-
+
include Printer
attr_reader :controller
@@ -55,13 +55,13 @@ def printer
end
def vars
- meta_vars = self.class.meta_vars || []
+ meta_vars = self.class.meta_vars || []
@vars ||= meta_vars.inject([]) do |vars, meta_var|
vars << meta_var.value(controller) if meta_var
vars
end
end
-
+
def js_events
self.class.js_events ||= []
end
View
@@ -22,13 +22,13 @@ def omniture_flash
def omniture_url
ssl = :ssl if request.ssl? && OmnitureClient::ssl_url
reporter.url(ssl)
- end
-
+ end
+
def omniture_js
ssl = :ssl if request.ssl? && OmnitureClient::ssl_url
reporter.js(ssl)
- end
-
+ end
+
def omniture_raw
reporter.raw
end
@@ -38,21 +38,19 @@ def omniture_raw
def set_reporter
@reporter ||= begin
"#{controller_path.classify}Reporter".constantize.new(self)
- #rescue NameError
- # BasicReporter.new(self)
- end
+ rescue NameError
+ BasicReporter.new(self)
+ end
end
def assign_flash_vars
reporter.class.clear_meta_vars unless omniture_flash.empty?
omniture_flash.each do |name, value|
reporter.add_var(name, value)
- end
+ end
end
end
end
end
ActionController::Base.send(:include, OmnitureClient::ActionControllerMethods) if defined?(ActionController::Base)
-
-# OmnitureClient::config(YAML::load(File.open('config/omniture.yml'))[Rails.env]) if File.exists?('config/omniture.yml')

0 comments on commit 76dd471

Please sign in to comment.