Class: Picky::Indexers::Base
Instance Attribute Summary collapse
-
#index_or_category ⇒ Object
readonly
Returns the value of attribute index_or_category.
Instance Method Summary collapse
- #check(source) ⇒ Object
-
#initialize(index_or_category) ⇒ Base
constructor
A new instance of Base.
- #notify_finished(prepared_file) ⇒ Object
-
#prepare(categories, scheduler = Scheduler.new) ⇒ Object
Starts the indexing process.
-
#reset(source) ⇒ Object
Explicitly reset the source to avoid caching trouble.
Constructor Details
#initialize(index_or_category) ⇒ Base
Returns a new instance of Base.
16 17 18 |
# File 'lib/picky/indexers/base.rb', line 16 def initialize index_or_category @index_or_category = index_or_category end |
Instance Attribute Details
#index_or_category ⇒ Object (readonly)
Returns the value of attribute index_or_category.
11 12 13 |
# File 'lib/picky/indexers/base.rb', line 11 def index_or_category @index_or_category end |
Instance Method Details
#check(source) ⇒ Object
38 39 40 |
# File 'lib/picky/indexers/base.rb', line 38 def check source raise "Trying to index without a source for #{@index_or_category.name}." unless source end |
#notify_finished(prepared_file) ⇒ Object
42 43 44 |
# File 'lib/picky/indexers/base.rb', line 42 def notify_finished prepared_file Picky.logger.tokenize @index_or_category, prepared_file end |
#prepare(categories, scheduler = Scheduler.new) ⇒ Object
Starts the indexing process.
22 23 24 25 26 27 28 29 |
# File 'lib/picky/indexers/base.rb', line 22 def prepare categories, scheduler = Scheduler.new source_for_prepare = source check source_for_prepare categories.empty process source_for_prepare, categories, scheduler do |prepared_file| notify_finished prepared_file end end |
#reset(source) ⇒ Object
Explicitly reset the source to avoid caching trouble.
33 34 35 36 |
# File 'lib/picky/indexers/base.rb', line 33 def reset source source.reset if source.respond_to?(:reset) source.reconnect! if source.respond_to?(:reconnect!) end |