Class: Schlepper::Task
- Inherits:
-
Object
- Object
- Schlepper::Task
- Includes:
- AbstractMethodHelper
- Defined in:
- lib/schlepper/task.rb
Overview
Tasks live in your rails app under /script/tasks. They have the same filename pattern as rails migrations, time stamp_class_name.rb A functional generator is provided using ‘rails generate schlepper:task name_of_task`
Class Method Summary collapse
Instance Method Summary collapse
-
#controls_transaction? ⇒ Boolean
Signals to the task runner that this task will control its own transaction.
-
#description ⇒ String
abstract
Short note on the intent of this script.
-
#owner ⇒ String
abstract
Name of the person or people who have ownership of the script.
-
#run ⇒ Bool
abstract
This is the entry point for your script.
-
#version_number ⇒ Fixnum
The version number of the current class.
Methods included from AbstractMethodHelper
Class Method Details
.children ⇒ Object
10 11 12 |
# File 'lib/schlepper/task.rb', line 10 def self.children @children end |
.inherited(obj) ⇒ Object
14 15 16 17 |
# File 'lib/schlepper/task.rb', line 14 def self.inherited obj super children.push obj end |
Instance Method Details
#controls_transaction? ⇒ Boolean
Signals to the task runner that this task will control its own transaction. When true the task runner will not open a transaction. Use with caution.
30 31 32 |
# File 'lib/schlepper/task.rb', line 30 def controls_transaction? false end |
#description ⇒ String
Returns Short note on the intent of this script.
36 37 |
# File 'lib/schlepper/task.rb', line 36 abstract def description end |
#owner ⇒ String
Returns Name of the person or people who have ownership of the script.
41 42 |
# File 'lib/schlepper/task.rb', line 41 abstract def owner end |
#run ⇒ Bool
This is the entry point for your script. The full Rails stack is available. Return true if it was successful, false if not. If not successful, set @failure_message to something meaningful. Runs that return false will not be marked as run and will be continue to be run in subsequent batch runs
51 52 |
# File 'lib/schlepper/task.rb', line 51 abstract def run end |
#version_number ⇒ Fixnum
Returns The version number of the current class.
20 21 22 23 24 |
# File 'lib/schlepper/task.rb', line 20 def version_number # We have to find the actual file where the class is defined which is the reason for # the method source location weirdness @version_number ||= File.basename(method(:run).source_location.first).scan(/\A(\d{10,})/).first.first end |