class Sunspot::SessionProxy::ClassShardingSessionProxy

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.

Public Instance Methods

remove_all(clazz = nil) click to toggle source

See Sunspot.remove_all

# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 42
def remove_all(clazz = nil)
  if clazz
    session_for_class(clazz).remove_all(clazz)
  else
    all_sessions.each { |session| session.remove_all }
  end
end
remove_all!(clazz = nil) click to toggle source

See Sunspot.remove_all!

# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 53
def remove_all!(clazz = nil)
  if clazz
    session_for_class(clazz).remove_all!(clazz)
  else
    all_sessions.each { |session| session.remove_all! }
  end
end
remove_by_id(clazz, *ids) click to toggle source

See Sunspot.remove_by_id

# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 26
def remove_by_id(clazz, *ids)
  ids.flatten!
  session_for_class(clazz).remove_by_id(clazz, ids)
end
remove_by_id!(clazz, *ids) click to toggle source

See Sunspot.remove_by_id!

# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 34
def remove_by_id!(clazz, *ids)
  ids.flatten!
  session_for_class(clazz).remove_by_id!(clazz, ids)
end
session_for_class(clazz) click to toggle source

Remove the Session object pointing at the shard that indexes the given class.

<strong>Concrete subclasses must implement this method.</strong>

# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 19
def session_for_class(clazz)
  raise NotImplementedError
end

Private Instance Methods

session_for(object) click to toggle source
# File lib/sunspot/session_proxy/class_sharding_session_proxy.rb, line 63
def session_for(object)
  session_for_class(object.class)
end