Class: Ferret::Index::LazyDoc
- Inherits:
-
Object
- Object
- Ferret::Index::LazyDoc
- Defined in:
- ext/isomorfeus_ferret_ext/frb_lazy_doc.c
Overview
Summary
When a document is retrieved from the index a LazyDoc is returned. It inherits from rubys Hash class, however it is read only. LazyDoc lazily adds fields to itself when they are accessed or automatically loads all fields if needed. To load all fields use the LazyDoc#load method. Methods from the Hash class, that would modify the LazyDoc itself, are not supported, .
Example
doc = index_reader[0]
doc.keys #=> []
doc.values #=> []
doc.fields #=> [:title, :content]
title = doc[:title] #=> "the title"
doc.keys #=> [:title]
doc.values #=> ["the title"]
doc.fields #=> [:title, :content]
doc.load
doc.keys #=> [:title, :content]
doc.values #=> ["the title", "the content"]
doc.fields #=> [:title, :content]