Module: Split

Extended by:
Split
Included in:
Split
Defined in:
lib/split.rb,
lib/split/trial.rb,
lib/split/engine.rb,
lib/split/helper.rb,
lib/split/metric.rb,
lib/split/version.rb,
lib/split/dashboard.rb,
lib/split/exceptions.rb,
lib/split/experiment.rb,
lib/split/alternative.rb,
lib/split/persistence.rb,
lib/split/configuration.rb,
lib/split/dashboard/helpers.rb,
lib/split/algorithms/whiplash.rb,
lib/split/algorithms/weighted_sample.rb,
lib/split/persistence/cookie_adapter.rb,
lib/split/persistence/session_adapter.rb

Defined Under Namespace

Modules: Algorithms, DashboardHelpers, Helper, Persistence Classes: Alternative, Configuration, Dashboard, Engine, Experiment, ExperimentNotFound, InvalidExperimentsFormatError, InvalidPersistenceAdapterError, Metric, Trial

Constant Summary collapse

MAJOR =
0
MINOR =
6
PATCH =
2
VERSION =
[MAJOR, MINOR, PATCH].join('.')

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration


10
11
12
# File 'lib/split.rb', line 10

def configuration
  @configuration
end

Instance Method Details

#configure {|configuration| ... } ⇒ Object

Call this method to modify defaults in your initializers.

Examples:

Split.configure do |config|
  config.ignore_ip_addresses = '192.168.2.1'
end

Yields:


53
54
55
56
# File 'lib/split.rb', line 53

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

#redisObject

Returns the current Redis connection. If none has been created, will create a new one.


41
42
43
44
45
# File 'lib/split.rb', line 41

def redis
  return @redis if @redis
  self.redis = 'localhost:6379'
  self.redis
end

#redis=(server) ⇒ Object

Accepts:

1. A 'hostname:port' string
2. A 'hostname:port:db' string (to select the Redis db)
3. A 'hostname:port/namespace' string (to set the Redis namespace)
4. A redis URL string 'redis://host:port'
5. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
   or `Redis::Namespace`.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/split.rb', line 19

def redis=(server)
  if server.respond_to? :split
    if server["redis://"]
      redis = Redis.connect(:url => server, :thread_safe => true)
    else
      server, namespace = server.split('/', 2)
      host, port, db = server.split(':')
      redis = Redis.new(:host => host, :port => port,
        :thread_safe => true, :db => db)
    end
    namespace ||= :split

    @redis = Redis::Namespace.new(namespace, :redis => redis)
  elsif server.respond_to? :namespace=
    @redis = server
  else
    @redis = Redis::Namespace.new(:split, :redis => server)
  end
end