Module: SuckerPunch::Backgroundable

Defined in:
lib/sucker_punch/backgroundable/backgroundable.rb,
lib/sucker_punch/backgroundable/job.rb,
lib/sucker_punch/backgroundable/util.rb,
lib/sucker_punch/backgroundable/config.rb

Overview

Backgroundable provides mechanism for executing an object’s methods asynchronously.

Defined Under Namespace

Modules: BackgroundableClassMethods, CallMethod, Util Classes: BackgroundProxy, Configuration, Job, JobRunner

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



5
6
7
# File 'lib/sucker_punch/backgroundable/config.rb', line 5

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



8
9
10
11
# File 'lib/sucker_punch/backgroundable/config.rb', line 8

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.included(base) ⇒ Object



11
12
13
# File 'lib/sucker_punch/backgroundable/backgroundable.rb', line 11

def self.included(base)
  base.extend(BackgroundableClassMethods)
end

Instance Method Details

#background(options = { }) ⇒ Object

Allows you to background any method that has not been marked as a backgrounded method via SuckerPunch::Backgroundable::BackgroundableClassMethods#always_background.



17
18
19
# File 'lib/sucker_punch/backgroundable/backgroundable.rb', line 17

def background(options = { })
  BackgroundProxy.new(self, options)
end

#later(seconds, options = { }) ⇒ Object

Allows you to background any method that has not been marked as a backgrounded method via SuckerPunch::Backgroundable::BackgroundableClassMethods#always_background. The method will not be executed immediately, but only after ‘seconds’ seconds.



24
25
26
# File 'lib/sucker_punch/backgroundable/backgroundable.rb', line 24

def later(seconds, options = { })
  BackgroundProxy.new(self, options, seconds)
end