Class: Blendris::RedisInteger
- Inherits:
-
Object
- Object
- Blendris::RedisInteger
- Includes:
- RedisNode
- Defined in:
- lib/blendris/integer.rb
Overview
RedisInteger is a string-value in Redis wrapped up to make sure that it is used as an integer.
Instance Attribute Summary
Attributes included from RedisNode
Class Method Summary collapse
Instance Method Summary collapse
Methods included from RedisNode
#clear, #exists?, #get, #initialize, #notify_changed, #rename, #set, #type
Methods included from RedisAccessor
database=, flushdb, #generate_key, #in_temporary_set, redis, #redis
Methods included from Utils
#blank, #camelize, #constantize, #sanitize_key
Class Method Details
.cast_from_redis(value, options = {}) ⇒ Object
16 17 18 |
# File 'lib/blendris/integer.rb', line 16 def self.cast_from_redis(value, = {}) value.to_i if value end |
.cast_to_redis(value, options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/blendris/integer.rb', line 10 def self.cast_to_redis(value, = {}) raise TypeError.new("#{value.class.name} is not an integer") unless value.kind_of? Fixnum value.to_s end |
Instance Method Details
#decrement ⇒ Object
24 25 26 |
# File 'lib/blendris/integer.rb', line 24 def decrement redis.decr key end |
#increment ⇒ Object
20 21 22 |
# File 'lib/blendris/integer.rb', line 20 def increment redis.incr key end |