Module: Analytical

Defined in:
lib/analytical.rb,
lib/analytical/api.rb,
lib/analytical/bot_detector.rb,
lib/analytical/modules/base.rb,
lib/analytical/rails/engine.rb,
lib/analytical/command_store.rb,
lib/analytical/modules/adroll.rb,
lib/analytical/modules/clicky.rb,
lib/analytical/modules/google.rb,
lib/analytical/modules/adwords.rb,
lib/analytical/modules/console.rb,
lib/analytical/modules/hubspot.rb,
lib/analytical/modules/comscore.rb,
lib/analytical/modules/loopfuse.rb,
lib/analytical/modules/mixpanel.rb,
lib/analytical/modules/chartbeat.rb,
lib/analytical/modules/crazy_egg.rb,
lib/analytical/modules/quantcast.rb,
lib/analytical/modules/click_tale.rb,
lib/analytical/modules/optimizely.rb,
lib/analytical/modules/kiss_metrics.rb,
lib/analytical/modules/reinvigorate.rb,
lib/analytical/modules/microsoft_ads.rb,
lib/analytical/modules/performancing.rb,
lib/analytical/session_command_store.rb,
lib/analytical/modules/google_optimizer.rb

Defined Under Namespace

Modules: BotDetector, HelperMethods, InstanceMethods, Modules, Rails Classes: Api, CommandStore, SessionCommandStore

Instance Method Summary collapse

Instance Method Details

#analytical(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/analytical.rb', line 9

def analytical(options={})
  self.analytical_options = options

  config_options = { :modules => [] }
  File.open("#{::Rails.root}/config/analytical.yml") do |f|
    file_options = YAML::load(ERB.new(f.read).result).symbolize_keys
    env = (::Rails.env || :production).to_sym
    file_options = file_options[env] if file_options.has_key?(env)
    file_options.each do |k, v|
      if v.respond_to?(:symbolize_keys)
        # module configuration
        config_options[k.to_sym] = v.symbolize_keys
        config_options[:modules] << k.to_sym unless options && options[:modules]
      else
        # regular option
        config_options[k.to_sym] = v
      end
    end if file_options
  end if File.exists?("#{::Rails.root}/config/analytical.yml")

  self.analytical_options = self.analytical_options.reverse_merge config_options
end