Module: Split

Extended by:
Split
Included in:
Split
Defined in:
lib/split/encapsulated_helper.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/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/algorithms/whiplash.rb,
lib/split/dashboard/paginator.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.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

Instance Method Details

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



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

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:



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

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.



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

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


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

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