Module: Ablab::Helper

Included in:
ApplicationController
Defined in:
lib/ablab/helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/ablab/helper.rb', line 5

def self.included(klass)
  if klass.respond_to? :helper_method
    self.instance_methods(false).each do |method|
      klass.send(:helper_method, method)
      klass.send(:private, method)
    end
  end
end

Instance Method Details

#ablab_session_idObject



23
24
25
# File 'lib/ablab/helper.rb', line 23

def ablab_session_id
  cookies[:ablab_sid] || cookies[:ablab_sid] = SecureRandom.hex
end

#experiment(name) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ablab/helper.rb', line 14

def experiment(name)
  @experiments ||= {}
  unless Ablab.experiments.has_key?(name)
    raise "No experiment with name #{name}"
  end
  @experiments[name] ||=
    Ablab.experiments[name].run(ablab_session_id, request)
end