Module: Friendable
- Extended by:
- Friendable
- Included in:
- Friendable
- Defined in:
- lib/friendable.rb,
lib/friendable/version.rb,
lib/friendable/exceptions.rb,
lib/friendable/friendship.rb,
lib/friendable/user_methods.rb
Defined Under Namespace
Modules: UserMethods Classes: Error, Friendship, FriendshipNotFound
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#resource_class ⇒ Object
Returns the value of attribute resource_class.
Instance Method Summary collapse
- #redis ⇒ Object
-
#redis=(server) ⇒ Object
Accepts: 1.
Instance Attribute Details
#resource_class ⇒ Object
Returns the value of attribute resource_class.
9 10 11 |
# File 'lib/friendable.rb', line 9 def resource_class @resource_class end |
Instance Method Details
#redis ⇒ Object
11 12 13 |
# File 'lib/friendable.rb', line 11 def redis @redis ||= Redis::Namespace.new(:friendable, :redis => Redis.new) 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`.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/friendable.rb', line 22 def redis=(server) case server when String 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 ||= :friendable @redis = Redis::Namespace.new(namespace, :redis => redis) when Redis::Namespace @redis = server else @redis = Redis::Namespace.new(:friendable, :redis => server) end end |