Class: Sunspot::SessionProxy::DelayedJob::IndexingJob

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy, method, *args, &block) ⇒ IndexingJob

Returns a new instance of IndexingJob.



13
14
15
16
17
18
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 13

def initialize(proxy, method, *args, &block)
  @session = proxy.session
  @proxy = proxy
  @method = method
  @args = args
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



11
12
13
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 11

def method
  @method
end

#proxyObject (readonly)

Returns the value of attribute proxy.



11
12
13
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 11

def proxy
  @proxy
end

#sessionObject (readonly)

Returns the value of attribute session.



11
12
13
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 11

def session
  @session
end

Instance Method Details

#performObject



24
25
26
27
28
29
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 24

def perform
  # Delayed job serializes ruby objects to yaml.
  # Yaml doesn't rebuild the LightConfiguration object correctly so we need to brute force a rebuild of the configuration
  rebuild_config
  @args ? @session.send(method, *@args) : @session.send(method)
end

#rebuild_configObject



20
21
22
# File 'lib/sunspot_plus/session_proxy/delayed_job/indexing_job.rb', line 20

def rebuild_config
  @session.instance_variable_set("@config", proxy.class.rebuild_config(session.config))
end