Class: Blendris::RedisInteger
- 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 inherited from RedisNode
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from RedisNode
#clear, #exists?, #get, #initialize, #notify_changed, #rename, #set, #type
Methods included from RedisAccessor
#generate_key, #in_temporary_set, redis, #redis
Methods included from Utils
#blank, #camelize, #constantize, #pairify, #sanitize_key
Constructor Details
This class inherits a constructor from Blendris::RedisNode
Class Method Details
.cast_from_redis(value, options = {}) ⇒ Object
14 15 16 |
# File 'lib/blendris/integer.rb', line 14 def self.cast_from_redis(value, = {}) value.to_i if value end |
.cast_to_redis(value, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/blendris/integer.rb', line 8 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 27 28 |
# File 'lib/blendris/integer.rb', line 24 def decrement redis.decr key ensure notify_changed end |
#increment ⇒ Object
18 19 20 21 22 |
# File 'lib/blendris/integer.rb', line 18 def increment redis.incr key ensure notify_changed end |