Class: Stellr::Collections::Base

Inherits:
Object
  • Object
show all
Includes:
Ferret::Index, Utils::Observable, Utils::Shutdown
Defined in:
lib/stellr/collections/base.rb

Overview

Base class for collection implementations

Direct Known Subclasses

SearchableCollection

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Observable

#add_listener, #listeners, #notify_listeners

Methods included from Utils::Shutdown

#shutdown, #shutting_down?

Constructor Details

#initialize(name, options) ⇒ Base

Returns a new instance of Base.



23
24
25
26
27
# File 'lib/stellr/collections/base.rb', line 23

def initialize( name, options )
  @logger = options[:logger]
  @name = name
  @options = options.dup
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/stellr/collections/base.rb', line 9

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/stellr/collections/base.rb', line 9

def name
  @name
end

Class Method Details

.create(name, options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stellr/collections/base.rb', line 11

def self.create( name, options )
  log = (options[:logger] ||= (require 'logger'; Logger.new 'stellr.log'))
  collection_class = collection_class_for_options options
  collection       = collection_class.new( name, options )
  if strategy_class = strategy_class_for_options( options )
    log.debug "using strategy #{strategy_class}"
    strategy_class.new( collection, options )
  else
    collection
  end
end

Instance Method Details

#batch_finishedObject

called whenever the strategy thinks it’s a good time do do something timeconsuming (like switching indexes, optimizing, flushing, …)



31
32
# File 'lib/stellr/collections/base.rb', line 31

def batch_finished
end

#closeObject

close this collection



39
40
# File 'lib/stellr/collections/base.rb', line 39

def close
end

#on_shutdown(mode) ⇒ Object



34
35
36
# File 'lib/stellr/collections/base.rb', line 34

def on_shutdown( mode )
  close
end