-
Notifications
You must be signed in to change notification settings - Fork 49
Sources Configuration
floere edited this page Dec 16, 2011
·
32 revisions
Sources tell an index where to get its data.
Quick Example
Each Method
Source Method
Examples
Picky gets its data from traversing the data through the #each
method of whatever you give it as source.
For example, this could be an ActiveRecord object.
Picky::Index.new(:books) do
source {}
end
As you’ve seen, you tell the Picky::Index
where to get the data by calling source inside the index definition. There’s two ways:
- with a block (delayed execution when the index is indexing)
- without a block (execution as soon as the index definition is evaluated)
What’s the difference?
Picky::Index.new(:books) do
source { Book.order('title DESC') }
end
This will be executed each time the books are indexed.
Picky::Index.new(:books) do
source Book.order('title DESC').all
end
This will be executed each time the index definition is read. So once for all indexing.