Module: Redis::Attrs
- Defined in:
- lib/redis-attrs.rb,
lib/redis-attrs/base.rb,
lib/redis-attrs/date.rb,
lib/redis-attrs/hash.rb,
lib/redis-attrs/list.rb,
lib/redis-attrs/time.rb,
lib/redis-attrs/float.rb,
lib/redis-attrs/scalar.rb,
lib/redis-attrs/string.rb,
lib/redis-attrs/boolean.rb,
lib/redis-attrs/complex.rb,
lib/redis-attrs/integer.rb,
lib/redis-attrs/version.rb,
lib/redis-attrs/objects_extensions.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Classes: Base, Boolean, Complex, Date, FilteredList, FilteredSet, Float, Hash, Integer, List, Scalar, String, Time
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.included(receiver) ⇒ Object
48
49
50
51
|
# File 'lib/redis-attrs.rb', line 48
def self.included(receiver)
receiver.extend(ClassMethods)
receiver.send(:include, InstanceMethods)
end
|
.redis ⇒ Object
7
8
9
10
|
# File 'lib/redis-attrs.rb', line 7
def self.redis
@redis || $redis || Redis.current ||
raise(NotConnected, "Redis::Attrs.redis not set to a valid redis connection")
end
|
.redis=(r) ⇒ Object
12
13
14
|
# File 'lib/redis-attrs.rb', line 12
def self.redis=(r)
@redis = r
end
|
.register_type(type, klass) ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/redis-attrs.rb', line 73
def self.register_type(type, klass)
type = type.to_sym
raise ArgumentError, "Redis attr type #{type} is already defined" if supported_types.include?(type)
unless klass.ancestors.include?(Scalar)
raise ArgumentError, "Class implementing new type #{type} must be a subclass of Redis::Attrs::Scalar"
end
@supported_types[type] = klass
end
|
.supported_types ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/redis-attrs.rb', line 53
def self.supported_types
@supported_types ||= {
string: Redis::Attrs::String,
boolean: Redis::Attrs::Boolean,
date: Redis::Attrs::Date,
time: Redis::Attrs::Time,
integer: Redis::Attrs::Integer,
float: Redis::Attrs::Float,
counter: Redis::Attrs::Complex,
lock: Redis::Attrs::Complex,
hash: Redis::Attrs::Hash,
list: Redis::Attrs::List,
set: Redis::Attrs::List,
sorted_set: Redis::Attrs::Hash,
}
end
|