Class: Stellr::Collections::Base
- Inherits:
-
Object
- Object
- Stellr::Collections::Base
- Includes:
- Ferret::Index, Utils::Observable, Utils::Shutdown
- Defined in:
- lib/stellr/collections/base.rb
Overview
Base class for collection implementations
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#batch_finished ⇒ Object
called whenever the strategy thinks it’s a good time do do something timeconsuming (like switching indexes, optimizing, flushing, …).
-
#close ⇒ Object
close this collection.
-
#initialize(name, options) ⇒ Base
constructor
A new instance of Base.
- #on_shutdown(mode) ⇒ Object
Methods included from Utils::Observable
#add_listener, #listeners, #notify_listeners
Methods included from Utils::Shutdown
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, ) @logger = [:logger] @name = name @options = .dup end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/stellr/collections/base.rb', line 9 def logger @logger end |
#name ⇒ Object (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, ) log = ([:logger] ||= (require 'logger'; Logger.new 'stellr.log')) collection_class = collection = collection_class.new( name, ) if strategy_class = ( ) log.debug "using strategy #{strategy_class}" strategy_class.new( collection, ) else collection end end |
Instance Method Details
#batch_finished ⇒ Object
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 |
#close ⇒ Object
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 |