Skip to content

Instantly share code, notes, and snippets.

@adamcooper
Created March 13, 2012 17:28
Show Gist options
  • Save adamcooper/2030051 to your computer and use it in GitHub Desktop.
Save adamcooper/2030051 to your computer and use it in GitHub Desktop.
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}"
@tjwallace
Copy link

@adamcooper shouldn't you be setting up activity like this:

RedisNamespace.new(:activity, :redis => redis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment