Class: Sunspot::SessionProxy::ClassShardingSessionProxy
- Inherits:
-
ShardingSessionProxy
- Object
- AbstractSessionProxy
- ShardingSessionProxy
- Sunspot::SessionProxy::ClassShardingSessionProxy
- Defined in:
- sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb
Overview
An abstract subclass of ShardingSessionProxy that shards by class. Concrete subclasses should not override the #session_for method, but should instead implement the #session_for_class method. They must also still implement the #all_sessions method.
Unlike its parent class, ClassShardingSessionProxy implements #remove_by_id and all flavors of #remove_all.
Instance Method Summary (collapse)
-
- (Object) remove_all(clazz = nil)
See Sunspot.remove_all.
-
- (Object) remove_all!(clazz = nil)
See Sunspot.remove_all!.
-
- (Object) remove_by_id(clazz, id)
See Sunspot.remove_by_id.
-
- (Object) remove_by_id!(clazz, id)
See Sunspot.remove_by_id!.
-
- (Object) session_for_class(clazz)
Remove the Session object pointing at the shard that indexes the given class.
Methods inherited from ShardingSessionProxy
#all_sessions, #commit, #commit_if_delete_dirty, #commit_if_dirty, #delete_dirty?, #dirty?, #index, #index!, #initialize, #more_like_this, #new_more_like_this, #new_search, #optimize, #remove, #remove!, #search
Methods inherited from AbstractSessionProxy
Constructor Details
This class inherits a constructor from Sunspot::SessionProxy::ShardingSessionProxy
Instance Method Details
- (Object) remove_all(clazz = nil)
See Sunspot.remove_all
40 41 42 43 44 45 46 |
# File 'sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb', line 40 def remove_all(clazz = nil) if clazz session_for_class(clazz).remove_all(clazz) else all_sessions.each { |session| session.remove_all } end end |
- (Object) remove_all!(clazz = nil)
See Sunspot.remove_all!
51 52 53 54 55 56 57 |
# File 'sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb', line 51 def remove_all!(clazz = nil) if clazz session_for_class(clazz).remove_all!(clazz) else all_sessions.each { |session| session.remove_all! } end end |
- (Object) remove_by_id(clazz, id)
See Sunspot.remove_by_id
26 27 28 |
# File 'sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb', line 26 def remove_by_id(clazz, id) session_for_class(clazz).remove_by_id(clazz, id) end |
- (Object) remove_by_id!(clazz, id)
See Sunspot.remove_by_id!
33 34 35 |
# File 'sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb', line 33 def remove_by_id!(clazz, id) session_for_class(clazz).remove_by_id!(clazz, id) end |
- (Object) session_for_class(clazz)
Remove the Session object pointing at the shard that indexes the given class.
Concrete subclasses must implement this method.
19 20 21 |
# File 'sunspot/lib/sunspot/session_proxy/class_sharding_session_proxy.rb', line 19 def session_for_class(clazz) raise NotImplementedError end |