Class: Izanami::Mapper
- Inherits:
-
Object
- Object
- Izanami::Mapper
- Defined in:
- lib/izanami/mapper.rb
Overview
Proxy around a Redis client. It handles the configuration and the namespaces.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#client ⇒ Redis::Namespace
Redis client, with the namespace.
-
#initialize(options = {}) ⇒ Mapper
constructor
New Mapper client.
-
#redis ⇒ Redis::Client
Redis client, without the namespace.
-
#to_s ⇒ Object
Inspect the mapper.
Constructor Details
#initialize(options = {}) ⇒ Mapper
New Mapper client.
16 17 18 19 20 |
# File 'lib/izanami/mapper.rb', line 16 def initialize( = {}) @options = .dup @redis = @options.delete(:redis) @namespace = build_namespace(@options.delete(:namespace)) end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
9 10 11 |
# File 'lib/izanami/mapper.rb', line 9 def namespace @namespace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/izanami/mapper.rb', line 9 def @options end |
Instance Method Details
#client ⇒ Redis::Namespace
Redis client, with the namespace.
42 43 44 |
# File 'lib/izanami/mapper.rb', line 42 def client @client ||= initialize_client end |
#redis ⇒ Redis::Client
Redis client, without the namespace.
35 36 37 |
# File 'lib/izanami/mapper.rb', line 35 def redis @redis ||= initialize_redis end |
#to_s ⇒ Object
Inspect the mapper
57 58 59 60 61 62 |
# File 'lib/izanami/mapper.rb', line 57 def to_s(*) name = self.class.name info = redis.inspect "<#{name} connected to #{info} with @namespace=\"#{@namespace}\">" end |