Class: SharedWorkforce::TaskResult
- Inherits:
-
Object
- Object
- SharedWorkforce::TaskResult
- Defined in:
- lib/shared_workforce/task_result.rb
Instance Attribute Summary collapse
-
#callback_params ⇒ Object
readonly
Returns the value of attribute callback_params.
-
#name ⇒ Object
Returns the value of attribute name.
-
#responses ⇒ Object
Returns the value of attribute responses.
-
#status ⇒ Object
Returns the value of attribute status.
-
#task_hash ⇒ Object
Returns the value of attribute task_hash.
Instance Method Summary collapse
-
#initialize(params) ⇒ TaskResult
constructor
A new instance of TaskResult.
- #process! ⇒ Object
- #usernames ⇒ Object
Constructor Details
#initialize(params) ⇒ TaskResult
Returns a new instance of TaskResult.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/shared_workforce/task_result.rb', line 10 def initialize(params) params = params.with_indifferent_access self.task_hash = if params[:task] params[:task] else params end @responses = TaskResponse.create_collection_from_array(task_hash[:responses]) if task_hash[:responses] self.name = callback_params[:_task][:class_name] if callback_params && callback_params[:_task] && callback_params[:_task][:class_name] end |
Instance Attribute Details
#callback_params ⇒ Object (readonly)
Returns the value of attribute callback_params.
4 5 6 |
# File 'lib/shared_workforce/task_result.rb', line 4 def callback_params @callback_params end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/shared_workforce/task_result.rb', line 6 def name @name end |
#responses ⇒ Object
Returns the value of attribute responses.
5 6 7 |
# File 'lib/shared_workforce/task_result.rb', line 5 def responses @responses end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/shared_workforce/task_result.rb', line 7 def status @status end |
#task_hash ⇒ Object
Returns the value of attribute task_hash.
8 9 10 |
# File 'lib/shared_workforce/task_result.rb', line 8 def task_hash @task_hash end |
Instance Method Details
#process! ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/shared_workforce/task_result.rb', line 35 def process! if name && task = find_task(name) task.new(self) else raise TaskNotFound, "The task #{name} could not be found" end end |
#usernames ⇒ Object
31 32 33 |
# File 'lib/shared_workforce/task_result.rb', line 31 def usernames @responses.map(&:username).flatten end |