Module: Ratel::ActionViewExtension

Defined in:
lib/ratel/helper/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details

#screen_changes(*args, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ratel/helper/action_view_extension.rb', line 4

def screen_changes *args, &block
  options = args.extract_options!
  key = :"#{Ratel.config.screen_key}#{options[:at]}"

  ## TODO A/B テストの停止ロジック
  # redis などのkey-value 対応 or 設定ファイルでの制御?      
  if options[:with] == :reset or cookies[key].nil?
    selected = :default
    bar = 0
    num = Time.now.usec % 100
    options[:to].each do |k,v|
      bar += v
      if num < bar
        selected = k
        break
      end
    end
    cookies.permanent.signed[key] = selected
  end
  block.call cookies.signed[key]
end

#screen_conversion(category, action, label) ⇒ Object



26
27
28
29
# File 'lib/ratel/helper/action_view_extension.rb', line 26

def screen_conversion category, action, label
  # Ratel::Tracking::Event class is auto-defined
  Ratel::Tracking::Event.push category, action, label
end