Module: Split

Extended by:
Split
Included in:
Split
Defined in:
lib/split/algorithms/whiplash.rb,
lib/split.rb,
lib/split/user.rb,
lib/split/cache.rb,
lib/split/trial.rb,
lib/split/engine.rb,
lib/split/helper.rb,
lib/split/metric.rb,
lib/split/zscore.rb,
lib/split/version.rb,
lib/split/dashboard.rb,
lib/split/algorithms.rb,
lib/split/exceptions.rb,
lib/split/experiment.rb,
lib/split/alternative.rb,
lib/split/persistence.rb,
lib/split/configuration.rb,
lib/split/redis_interface.rb,
lib/split/goals_collection.rb,
lib/split/dashboard/helpers.rb,
lib/split/experiment_catalog.rb,
lib/split/dashboard/paginator.rb,
lib/split/encapsulated_helper.rb,
lib/split/persistence/dual_adapter.rb,
lib/split/persistence/redis_adapter.rb,
lib/split/algorithms/weighted_sample.rb,
lib/split/persistence/cookie_adapter.rb,
lib/split/combined_experiments_helper.rb,
lib/split/persistence/session_adapter.rb,
lib/split/dashboard/pagination_helpers.rb,
lib/split/algorithms/block_randomization.rb

Overview

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

Defined Under Namespace

Modules: Algorithms, CombinedExperimentsHelper, DashboardHelpers, DashboardPaginationHelpers, EncapsulatedHelper, Helper, Persistence Classes: Alternative, Cache, Configuration, Dashboard, DashboardPaginator, Engine, Experiment, ExperimentCatalog, ExperimentNotFound, GoalsCollection, InvalidExperimentsFormatError, InvalidPersistenceAdapterError, Metric, Railtie, RedisInterface, Trial, User, Zscore

Constant Summary collapse

VERSION =
"4.0.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



31
32
33
# File 'lib/split.rb', line 31

def configuration
  @configuration
end

Instance Method Details

#cache(namespace, key, &block) ⇒ Object



71
72
73
# File 'lib/split.rb', line 71

def cache(namespace, key, &block)
  Split::Cache.fetch(namespace, key, &block)
end

#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:



66
67
68
69
# File 'lib/split.rb', line 66

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.



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

def redis
  return @redis if @redis
  self.redis = self.configuration.redis
  self.redis
end

#redis=(server) ⇒ Object

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`.


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/split.rb', line 39

def redis=(server)
  @redis = if server.is_a?(String)
    Redis.new(url: server)
  elsif server.is_a?(Hash)
    Redis.new(server)
  elsif server.respond_to?(:smembers)
    server
  else
    raise ArgumentError,
      "You must supply a url, options hash or valid Redis connection instance"
  end
end