Module: Split
- Extended by:
- Split
- Included in:
- Split
- Defined in:
- lib/split.rb,
lib/split/helper.rb,
lib/split/version.rb,
lib/split/dashboard.rb,
lib/split/experiment.rb,
lib/split/alternative.rb,
lib/split/configuration.rb,
lib/split/dashboard/helpers.rb
Defined Under Namespace
Modules: DashboardHelpers, Helper Classes: Alternative, Configuration, Dashboard, Experiment
Constant Summary collapse
- VERSION =
"0.4.2"
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
-
#redis ⇒ Object
Returns the current Redis connection.
-
#redis=(server) ⇒ Object
Accepts: 1.
Instance Attribute Details
#configuration ⇒ Object
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.
53 54 55 56 |
# File 'lib/split.rb', line 53 def configure self.configuration ||= Configuration.new yield(configuration) end |
#redis ⇒ Object
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 |