Created
March 13, 2012 17:28
-
-
Save adamcooper/2030051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Redis | |
attr_accessor :server | |
end | |
class RedisNamespace | |
attr_accessor :redis | |
def initialize(namespace, options = {}) | |
self.redis = options[:redis] || :internal | |
end | |
def test | |
@redis | |
end | |
end | |
redis = Redis.new | |
redis.server = :external | |
activity = RedisNamespace.new(:activity, :redis => redis.server) | |
puts "redis.server = #{redis.server}" | |
puts "activity.redis = #{activity.test}" | |
# now change the server - similar to swapping in the specs | |
redis.server = :changed | |
puts "redis.server = #{redis.server}" | |
puts "activity.redis = #{activity.test}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@adamcooper shouldn't you be setting up
activity
like this: