Class: Trebuchet::Strategy::VisitorExperiment

Inherits:
Base
  • Object
show all
Includes:
Experimentable
Defined in:
lib/trebuchet/strategy/visitor_experiment.rb

Instance Attribute Summary

Attributes included from Experimentable

#bucket, #experiment_name, #total_buckets

Attributes inherited from Base

#feature

Instance Method Summary collapse

Methods included from Experimentable

#as_json, #export, #initialize_experiment, #inspect, #to_s, #type, #valid?, #value_in_bucket?

Methods inherited from Base

#as_json, #export, #feature_id, #inspect, #name, strategy_name

Constructor Details

#initialize(options = {}) ⇒ VisitorExperiment

Returns a new instance of VisitorExperiment.



5
6
7
# File 'lib/trebuchet/strategy/visitor_experiment.rb', line 5

def initialize(options = {})
  initialize_experiment(options)
end

Instance Method Details

#launch_at?(user, request = nil) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/trebuchet/strategy/visitor_experiment.rb', line 9

def launch_at?(user, request = nil)
 if Trebuchet.visitor_id.respond_to?(:call)
    visitor_id = Trebuchet.visitor_id.call(request)
  else
    visitor_id = nil
  end
  return false if visitor_id.nil?
  value_in_bucket?(visitor_id)
end

#needs_user?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/trebuchet/strategy/visitor_experiment.rb', line 19

def needs_user?
  false
end