Class: Flake
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Flake
- Includes:
- ActiveModel::Model
- Defined in:
- lib/flakes.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
- #on_failure(&callback) ⇒ Object
- #on_success(&callback) ⇒ Object
- #perform(args = {}) ⇒ Object
Class Method Details
.execute(args = {}) ⇒ Object
13 14 15 |
# File 'lib/flakes.rb', line 13 def self.execute(args = {}) new(args).execute end |
.execute_later(*args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/flakes.rb', line 17 def self.execute_later(*args) # initialize ActiveJob::Core only when Flake is enqueued to prevent conflics whith ActiveModel flake = new flake.send(:active_job_initialize, *args) flake.enqueue end |
Instance Method Details
#execute ⇒ Object
31 32 33 |
# File 'lib/flakes.rb', line 31 def execute(*) raise NotImplementedError, "no `execute` method defined for #{self.class}" end |
#on_failure(&callback) ⇒ Object
40 41 42 43 |
# File 'lib/flakes.rb', line 40 def on_failure(&callback) @failure = callback self end |
#on_success(&callback) ⇒ Object
35 36 37 38 |
# File 'lib/flakes.rb', line 35 def on_success(&callback) @success = callback self end |
#perform(args = {}) ⇒ Object
26 27 28 29 |
# File 'lib/flakes.rb', line 26 def perform(args = {}) args.each { |key, value| instance_variable_set(:"@#{key}", value) } execute end |