lib/redis/hash_key.rb in redis-objects-1.4.3 vs lib/redis/hash_key.rb in redis-objects-1.5.0

- old
+ new

@@ -1,18 +1,12 @@ -require File.dirname(__FILE__) + '/base_object' +require File.dirname(__FILE__) + '/enumerable_object' class Redis # # Class representing a Redis hash. # - class HashKey < BaseObject - require 'enumerator' - include Enumerable - require 'redis/helpers/core_commands' - include Redis::Helpers::CoreCommands - - attr_reader :key, :options + class HashKey < EnumerableObject def initialize(key, *args) super @options[:marshal_keys] ||= {} end @@ -72,15 +66,10 @@ h end alias_method :clone, :all alias_method :value, :all - # Enumerate through all fields. Redis: HGETALL - def each(&block) - all.each(&block) - end - # Enumerate through each keys. Redis: HKEYS def each_key(&block) keys.each(&block) end @@ -99,15 +88,10 @@ # Returns true if dict is empty def empty? true if size == 0 end - # Clears the dict of all keys/values. Redis: DEL - def clear - redis.del(key) - end - # Set keys in bulk, takes a hash of field/values {'field1' => 'val1'}. Redis: HMSET def bulk_set(*args) raise ArgumentError, "Argument to bulk_set must be hash of key/value pairs" unless args.last.is_a?(::Hash) allow_expiration do redis.hmset(key, *args.last.inject([]){ |arr,kv| @@ -180,12 +164,8 @@ end # Decrement value by float at field. Redis: HINCRBYFLOAT def decrbyfloat(field, by=1.0) incrbyfloat(field, -by) - end - - def as_json(*) - to_hash end end end