Module: UserTasks
- Defined in:
- lib/user_tasks.rb
Overview
Within TaxonWorks (not Rails) a tasks is a bit of work that references 2 or more data models at once, and that should be understandable without complicated context. Tasks should typically do a single thing well, however complex forms (sensu single page apps) fall into this category as well.
The UserTasks module provides developer support for tracking, testing, and integrating tasks.
Defined Under Namespace
Classes: UserTask
Constant Summary collapse
- CATEGORIES =
%w{nomenclature source collection_object collecting_event biology matrix dna image}.freeze
- TASK_DATA =
The raw YAML (Hash)
YAML.load_file(Rails.root + 'config/interface/hub/user_tasks.yml').freeze
- INDEXED_TASKS =
A Hash of prefix => UserTasks::UserTask
tasks.freeze
Class Method Summary collapse
-
.hub_tasks(category = nil) ⇒ Array
Of UserTasks::UserTask the UserTasks instances that have @hub == true.
-
.parameter_free_tasks ⇒ Array
Of UserTasks::UserTask the UserTasks instances that don’t require parameters (i.e. can be linked to from anywhere).
-
.related_name(prefix) ⇒ String
Translate a related prefix into a name string if present, else return the string as is.
- .related_routes(prefix) ⇒ UserTasks::UserTask?
-
.task(prefix) ⇒ UserTasks::UserTask?
A instance of a UserTasks::UserTask.
-
.tasks ⇒ Array
Of UserTasks::UserTask the UserTasks instances.
Class Method Details
.hub_tasks(category = nil) ⇒ Array
Returns of UserTasks::UserTask the UserTasks instances that have @hub == true.
145 146 147 148 149 150 |
# File 'lib/user_tasks.rb', line 145 def self.hub_tasks(category = nil) a = tasks.select{|t| t.hub} return a if category.nil? return [] if !CATEGORIES.include?(category) a.select{|b| b.categories.include?(category) } end |
.parameter_free_tasks ⇒ Array
Returns of UserTasks::UserTask the UserTasks instances that don’t require parameters (i.e. can be linked to from anywhere).
139 140 141 |
# File 'lib/user_tasks.rb', line 139 def self.parameter_free_tasks tasks.select{|t| !t.requires_params?} end |
.related_name(prefix) ⇒ String
Returns translate a related prefix into a name string if present, else return the string as is.
163 164 165 166 167 168 169 |
# File 'lib/user_tasks.rb', line 163 def self.(prefix) if t = INDEXED_TASKS[prefix] t.name else prefix end end |
.related_routes(prefix) ⇒ UserTasks::UserTask?
173 174 175 |
# File 'lib/user_tasks.rb', line 173 def self.(prefix) INDEXED_TASKS[prefix]. end |
.task(prefix) ⇒ UserTasks::UserTask?
Returns a instance of a UserTasks::UserTask.
156 157 158 |
# File 'lib/user_tasks.rb', line 156 def self.task(prefix) INDEXED_TASKS[prefix] end |
.tasks ⇒ Array
Returns of UserTasks::UserTask the UserTasks instances.
133 134 135 |
# File 'lib/user_tasks.rb', line 133 def self.tasks INDEXED_TASKS.values.sort!{|a, b| a.name <=> b.name } end |