module Split

Selects alternative with minimum count of participants If all counts are even (i.e. all are minimum), samples from all possible alternatives

Split's helper exposes all kinds of methods we don't want to mix into our model classes.

This module exposes only two methods:

- ab_test()
- ab_finished()

that can safely be mixed into any class.

Passes the instance of the class that it's mixed into to the Split persistence adapter as context.

Constants

MAJOR
MINOR
PATCH
VERSION

Attributes

configuration[RW]

Public Instance Methods

configure() { |configuration| ... } click to toggle source

Call this method to modify defaults in your initializers.

@example

Split.configure do |config|
  config.ignore_ip_addresses = '192.168.2.1'
end
# File lib/split.rb, line 63
def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end
redis() click to toggle source

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

# File lib/split.rb, line 51
def redis
  return @redis if @redis
  self.redis = self.configuration.redis
  self.redis
end
redis=(server) click to toggle source

Accepts:

1. A redis URL (valid for `Redis.new(url: url)`)
2. an options hash compatible with `Redis.new`
3. or a valid Redis instance (one that responds to `#smembers`). Likely,
   this will be an instance of either `Redis`, `Redis::Client`,
   `Redis::DistRedis`, or `Redis::Namespace`.
# File lib/split.rb, line 36
def redis=(server)
  @redis = if server.is_a?(String)
    Redis.new(:url => server, :thread_safe => true)
  elsif server.is_a?(Hash)
    Redis.new(server.merge(:thread_safe => true))
  elsif server.respond_to?(:smembers)
    server
  else
    raise ArgumentError,
      "You must supply a url, options hash or valid Redis connection instance"
  end
end