def index
case self.class.index
when Proc
self.class.index.call(self)
when Array
parts = self.class.index.collect { |meth|
unless self.respond_to? meth
raise NoIndex, "No such method: `#{meth}' for #{self.class}"
end
ret = self.send(meth)
ret = ret.index if ret.kind_of?(Familia)
ret
}
parts.join Familia.delim
when Symbol, String
if self.class.redis_object?(self.class.index.to_sym)
raise Familia::NoIndex, "Cannot use a RedisObject as an index"
else
unless self.respond_to? self.class.index
raise NoIndex, "No such method: `#{self.class.index}' for #{self.class}"
end
ret = self.send(self.class.index)
ret = ret.index if ret.kind_of?(Familia)
ret
end
else
raise Familia::NoIndex, self
end
end