Permalink
Browse files

tweaks and bugfixes

  • Loading branch information...
1 parent bccaa1f commit c432cd779d74eb846d62b49e78294c973bd4c2c2 @BrianTheCoder committed Nov 14, 2009
Showing with 26 additions and 6 deletions.
  1. +16 −0 lib/redis/counter.rb
  2. +3 −3 lib/redis/data_types.rb
  3. +5 −1 lib/redis/field_proxy.rb
  4. +2 −2 redis-types.gemspec
View
16 lib/redis/counter.rb
@@ -0,0 +1,16 @@
+class Redis::Counter
+ attr_accessor :redis, :key
+
+ def initialize(redis, key)
+ self.redis = redis
+ self.key = key
+ end
+
+ def incr
+ redis.incr(key)
+ end
+
+ def decr
+ redis.decr(key)
+ end
+end
View
6 lib/redis/data_types.rb
@@ -23,11 +23,11 @@ def from_redis(value); value && value.to_f end
end
module EpochTime
- def to_redis(value) Time.at(value.to_i) end
-
- def from_redis(value)
+ def to_redis(value)
value.is_a?(DateTime) ? value.to_time.to_i : value.to_i
end
+
+ def from_redis(value) Time.at(value.to_i) end
end
module DateTime
View
6 lib/redis/field_proxy.rb
@@ -5,9 +5,13 @@ module FieldProxy #:nodoc
def initialize(redis, marshal)
@redis = redis
@key = key
- @marshal = marshal
+ @marshal = marshal
check_for_redis_serialization
end
+
+ def marshal
+ @_mashall ||= @marshal.is_a?(String) ? Object.const_get(@marshal) : @marshal
+ end
def method_missing(method, *argv)
translated_method = translate_method_name(method)
View
4 redis-types.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{redis-types}
- s.version = "0.1.2"
+ s.version = "0.1.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["brianthecoder"]
- s.date = %q{2009-11-13}
+ s.date = %q{2009-11-14}
s.description = %q{this is so awesome it makes grown men cry}
s.email = %q{wbsmith83@gmail.com}
s.extra_rdoc_files = [

0 comments on commit c432cd7

Please sign in to comment.