Class: Sunspot::IndexQueue::SessionProxy
- Inherits:
-
SessionProxy::AbstractSessionProxy
- Object
- SessionProxy::AbstractSessionProxy
- Sunspot::IndexQueue::SessionProxy
- Defined in:
- lib/sunspot/index_queue/session_proxy.rb
Overview
This is a Sunspot::SessionProxy that works with the IndexQueue class. Most update requests will be added to the queue and be processed asynchronously. The exceptions are the remove
method with a block and the remove_all
method. These will send their commands directly to Solr since the queue cannot handle delete by query. You should avoid calling these methods
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#batch ⇒ Object
Does nothing in this implementation.
-
#commit ⇒ Object
Does nothing in this implementation.
-
#commit_if_delete_dirty ⇒ Object
Does nothing in this implementation.
-
#commit_if_dirty ⇒ Object
Does nothing in this implementation.
-
#delete_dirty? ⇒ Boolean
Always returns false in this implementation.
-
#dirty? ⇒ Boolean
Always returns false in this implementation.
-
#index(*objects) ⇒ Object
Queues up the index operation for later.
-
#index!(*objects) ⇒ Object
Queues up the index operation for later.
-
#initialize(queue = nil, session = nil) ⇒ SessionProxy
constructor
Create a new session proxy for a particular queue (default to a queue for all classes bound to the default session configuration).
-
#remove(*objects, &block) ⇒ Object
Queues up the remove operation for later unless a block is passed.
-
#remove!(*objects, &block) ⇒ Object
Queues up the remove operation for later unless a block is passed.
-
#remove_all(*classes) ⇒ Object
Proxies remove_all to the queue session.
-
#remove_all!(*classes) ⇒ Object
Proxies remove_all! to the queue session.
-
#remove_by_id(clazz, id) ⇒ Object
Queues up the index operation for later.
-
#remove_by_id!(clazz, id) ⇒ Object
Queues up the index operation for later.
Constructor Details
#initialize(queue = nil, session = nil) ⇒ SessionProxy
Create a new session proxy for a particular queue (default to a queue for all classes bound to the default session configuration). You can specify the session argument if the session used for queries should be different than the one the queue is bound to.
17 18 19 20 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 17 def initialize(queue = nil, session = nil) @queue = queue || IndexQueue.new @session = session || @queue.session end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
10 11 12 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 10 def queue @queue end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
10 11 12 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 10 def session @session end |
Instance Method Details
#batch ⇒ Object
Does nothing in this implementation.
23 24 25 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 23 def batch yield if block_given? end |
#commit ⇒ Object
Does nothing in this implementation.
28 29 30 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 28 def commit # no op end |
#commit_if_delete_dirty ⇒ Object
Does nothing in this implementation.
33 34 35 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 33 def commit_if_delete_dirty # no op end |
#commit_if_dirty ⇒ Object
Does nothing in this implementation.
38 39 40 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 38 def commit_if_dirty # no op end |
#delete_dirty? ⇒ Boolean
Always returns false in this implementation.
43 44 45 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 43 def delete_dirty? false end |
#dirty? ⇒ Boolean
Always returns false in this implementation.
48 49 50 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 48 def dirty? false end |
#index(*objects) ⇒ Object
Queues up the index operation for later.
53 54 55 56 57 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 53 def index(*objects) objects.flatten.each do |object| queue.index(object) end end |
#index!(*objects) ⇒ Object
Queues up the index operation for later.
60 61 62 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 60 def index!(*objects) index(*objects) end |
#remove(*objects, &block) ⇒ Object
Queues up the remove operation for later unless a block is passed. In that case it will be performed immediately.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 66 def remove(*objects, &block) if block # Delete by query not supported by queue, so send to server queue.session.remove(*objects, &block) else objects.flatten.each do |object| queue.remove(object) end end end |
#remove!(*objects, &block) ⇒ Object
Queues up the remove operation for later unless a block is passed. In that case it will be performed immediately.
79 80 81 82 83 84 85 86 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 79 def remove!(*objects, &block) if block # Delete by query not supported by queue, so send to server queue.session.remove!(*objects, &block) else remove(*objects) end end |
#remove_all(*classes) ⇒ Object
Proxies remove_all to the queue session.
89 90 91 92 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 89 def remove_all(*classes) # Delete by query not supported by queue, so send to server queue.session.remove_all(*classes) end |
#remove_all!(*classes) ⇒ Object
Proxies remove_all! to the queue session.
95 96 97 98 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 95 def remove_all!(*classes) # Delete by query not supported by queue, so send to server queue.session.remove_all!(*classes) end |
#remove_by_id(clazz, id) ⇒ Object
Queues up the index operation for later.
101 102 103 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 101 def remove_by_id(clazz, id) queue.remove(:class => clazz, :id => id) end |
#remove_by_id!(clazz, id) ⇒ Object
Queues up the index operation for later.
106 107 108 |
# File 'lib/sunspot/index_queue/session_proxy.rb', line 106 def remove_by_id!(clazz, id) remove_by_id(clazz, id) end |