lib/redis/objects/sets.rb in redis-objects-0.4.0 vs lib/redis/objects/sets.rb in redis-objects-0.4.1
- old
+ new
@@ -13,24 +13,25 @@
module ClassMethods
# Define a new list. It will function like a regular instance
# method, so it can be used alongside ActiveRecord, DataMapper, etc.
def set(name, options={})
@redis_objects[name.to_sym] = options.merge(:type => :set)
+ klass_name = '::' + self.name
if options[:global]
instance_eval <<-EndMethods
def #{name}
- @#{name} ||= Redis::Set.new(field_key(:#{name}), redis, @redis_objects[:#{name}])
+ @#{name} ||= Redis::Set.new(redis_field_key(:#{name}), #{klass_name}.redis, #{klass_name}.redis_objects[:#{name}])
end
EndMethods
class_eval <<-EndMethods
def #{name}
self.class.#{name}
end
EndMethods
else
class_eval <<-EndMethods
def #{name}
- @#{name} ||= Redis::Set.new(field_key(:#{name}), redis, self.class.redis_objects[:#{name}])
+ @#{name} ||= Redis::Set.new(redis_field_key(:#{name}), #{klass_name}.redis, #{klass_name}.redis_objects[:#{name}])
end
EndMethods
end
end
\ No newline at end of file