Class: Enum::RedisStore
- Inherits:
-
Object
- Object
- Enum::RedisStore
- Defined in:
- lib/enum/store/redis_store.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #get_value(key) ⇒ Object
-
#initialize(redis = nil) ⇒ RedisStore
constructor
A new instance of RedisStore.
- #load_hash(hash) ⇒ Object
- #load_yaml(file) ⇒ Object
- #set_value(key, value) ⇒ Object
Constructor Details
#initialize(redis = nil) ⇒ RedisStore
Returns a new instance of RedisStore.
8 9 10 |
# File 'lib/enum/store/redis_store.rb', line 8 def initialize(redis = nil) @connection = redis || Redis::Namespace.new(:enum, redis: Redis.new) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/enum/store/redis_store.rb', line 6 def connection @connection end |
Instance Method Details
#get_value(key) ⇒ Object
12 13 14 |
# File 'lib/enum/store/redis_store.rb', line 12 def get_value(key) Getter.get_value(connection, key) end |
#load_hash(hash) ⇒ Object
25 26 27 28 29 |
# File 'lib/enum/store/redis_store.rb', line 25 def load_hash(hash) hash.each_pair do |key, value| Setter.set_value(connection, key, value) end end |
#load_yaml(file) ⇒ Object
20 21 22 23 |
# File 'lib/enum/store/redis_store.rb', line 20 def load_yaml(file) require 'yaml' load_hash(YAML.load_file(file)) end |