Class: MaintenanceTasks::TaskDataShow Private
- Inherits:
-
Object
- Object
- MaintenanceTasks::TaskDataShow
- Defined in:
- app/models/maintenance_tasks/task_data_show.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class that represents the data related to a Task. Such information can be sourced from a Task or from existing Run records for a Task that was since deleted. This class contains detailed information such as the source code, associated runs, parameters, etc.
Instances of this class replace a Task class instance in cases where we don’t need the actual Task subclass.
Instance Attribute Summary collapse
-
#name ⇒ String
(also: #to_s)
readonly
private
The name of the Task.
Instance Method Summary collapse
-
#active_runs ⇒ ActiveRecord::Relation<MaintenanceTasks::Run>
private
Returns the set of currently active Run records associated with the Task.
-
#code ⇒ String?
private
The Task’s source code.
-
#completed_runs ⇒ ActiveRecord::Relation<MaintenanceTasks::Run>
private
Returns the set of completed Run records associated with the Task.
-
#csv_task? ⇒ Boolean
private
Whether the Task inherits from CsvTask.
-
#deleted? ⇒ Boolean
private
Whether the Task has been deleted.
-
#initialize(name) ⇒ TaskDataShow
constructor
private
Initializes a Task Data with a name and optionally a related run.
- #new ⇒ MaintenanceTasks::Task? private
-
#parameter_names ⇒ Array<String>
private
The names of parameters the Task accepts.
Constructor Details
#initialize(name) ⇒ TaskDataShow
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a Task Data with a name and optionally a related run.
17 18 19 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 17 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly) Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the name of the Task.
22 23 24 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 22 def name @name end |
Instance Method Details
#active_runs ⇒ ActiveRecord::Relation<MaintenanceTasks::Run>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the set of currently active Run records associated with the Task.
45 46 47 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 45 def active_runs @active_runs ||= runs.active end |
#code ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Task’s source code.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 29 def code return if deleted? task = Task.named(name) file = if Object.respond_to?(:const_source_location) Object.const_source_location(task.name).first else task.instance_method(:process).source_location.first end File.read(file) end |
#completed_runs ⇒ ActiveRecord::Relation<MaintenanceTasks::Run>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the set of completed Run records associated with the Task. This collection represents a historic of past Runs for information purposes, since the base for Task Data information comes primarily from currently active runs.
56 57 58 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 56 def completed_runs @completed_runs ||= runs.completed end |
#csv_task? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the Task inherits from CsvTask.
69 70 71 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 69 def csv_task? !deleted? && Task.named(name).has_csv_content? end |
#deleted? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether the Task has been deleted.
61 62 63 64 65 66 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 61 def deleted? Task.named(name) false rescue Task::NotFoundError true end |
#new ⇒ MaintenanceTasks::Task?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 87 88 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 84 def new return if deleted? MaintenanceTasks::Task.named(name).new end |
#parameter_names ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the names of parameters the Task accepts.
74 75 76 77 78 79 80 |
# File 'app/models/maintenance_tasks/task_data_show.rb', line 74 def parameter_names if deleted? [] else Task.named(name).attribute_names end end |