lib/redisable/key.rb in redisable-0.1.0 vs lib/redisable/key.rb in redisable-0.1.1

- old
+ new

@@ -10,16 +10,21 @@ def redis_key(name, options={}) klass_name ||= self.name define_method(name) do |id_=nil| id_ ||= if options[:id] options[:id].call(self) - else + elsif defined?(self.id) self.id end Key.join_key(klass_name, id_, name, options[:blank_field]) end + define_singleton_method(name) do |id_=nil| - id_ ||= options[:id].call(self) + id_ ||= if options[:id] + options[:id].call(self) + elsif defined?(self.id) + self.id + end Key.join_key(klass_name, id_, name, options[:blank_field]) end end end