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

CATEGORIES =
%w{nomenclature source collection_object collecting_event biology matrix dna}.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)

Class Method Details

+ (Array) hub_tasks

Returns of UserTasks::UserTask the UserTasks instances that have @hub == true

Returns:

  • (Array)

    of UserTasks::UserTask the UserTasks instances that have @hub == true



131
132
133
# File 'lib/user_tasks.rb', line 131

def self.hub_tasks
  tasks.select{|t| t.hub}
end

+ (Array) parameter_free_tasks

Returns of UserTasks::UserTask the UserTasks instances that don't require parameters (i.e. can be linked to from anywhere)

Returns:

  • (Array)

    of UserTasks::UserTask the UserTasks instances that don't require parameters (i.e. can be linked to from anywhere)



125
126
127
# File 'lib/user_tasks.rb', line 125

def self.parameter_free_tasks
  tasks.select{|t| !t.requires_params?}
end

Returns translate a related prefix into a name string if present, else return the string as is

Parameters:

  • prefix (String)

Returns:

  • (String)

    translate a related prefix into a name string if present, else return the string as is



146
147
148
149
150
151
152
# File 'lib/user_tasks.rb', line 146

def self.related_name(prefix)
  if t = INDEXED_TASKS[prefix]
    t.name
  else
    prefix
  end
end

Parameters:

  • prefix (String)

Returns:



156
157
158
# File 'lib/user_tasks.rb', line 156

def self.related_routes(prefix)
  INDEXED_TASKS[prefix].related
end

+ (UserTasks::UserTask?) task(prefix)

Returns a instance of a UserTasks::UserTask

Parameters:

  • prefix (String)

    A rails route prefix

Returns:



139
140
141
# File 'lib/user_tasks.rb', line 139

def self.task(prefix)
  INDEXED_TASKS[prefix]
end

+ (Array) tasks

Returns of UserTasks::UserTask the UserTasks instances

Returns:

  • (Array)

    of UserTasks::UserTask the UserTasks instances



119
120
121
# File 'lib/user_tasks.rb', line 119

def self.tasks
  INDEXED_TASKS.values.sort!{|a, b| a.name <=> b.name }
end