Class: Cellect::Server::Adapters::Default
- Inherits:
-
Object
- Object
- Cellect::Server::Adapters::Default
- Defined in:
- lib/cellect/server/adapters/default.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#load_data_for(workflow_name) ⇒ Object
Load the data for a workflow, this method: Accepts a workflow Returns an array of hashes in the form: { ‘id’ => 123, ‘priority’ => 0.123, ‘group_id’ => 456 }.
-
#load_user(workflow_name, id) ⇒ Object
Load seen ids for a user, this method: Accepts a workflow_name, and a user id Returns an array in the form: [1, 2, 3].
- #load_workflow(args) ⇒ Object
- #load_workflows(*names) ⇒ Object
-
#status ⇒ Object
Report adapter status as a Hash.
- #workflow_for(opts = { }) ⇒ Object
-
#workflow_list(*names) ⇒ Object
Return a list of workflows to load in the form: [{ ‘id’ => 123, ‘name’ => ‘foo’, ‘prioritized’ => false, ‘pairwise’ => false, ‘grouped’ => false }, …].
Instance Method Details
#load_data_for(workflow_name) ⇒ Object
Load the data for a workflow, this method:
Accepts a workflow
Returns an array of hashes in the form:
{
'id' => 123,
'priority' => 0.123,
'group_id' => 456
}
25 26 27 |
# File 'lib/cellect/server/adapters/default.rb', line 25 def load_data_for(workflow_name) raise NotImplementedError end |
#load_user(workflow_name, id) ⇒ Object
Load seen ids for a user, this method:
Accepts a workflow_name, and a user id
Returns an array in the form:
[1, 2, 3]
33 34 35 |
# File 'lib/cellect/server/adapters/default.rb', line 33 def load_user(workflow_name, id) raise NotImplementedError end |
#load_workflow(args) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cellect/server/adapters/default.rb', line 46 def load_workflow(args) info = if args.is_a?(Hash) args elsif args.is_a?(String) workflow_list.select{ |h| h['name'] == args }.first else raise ArgumentError end workflow_for info end |
#load_workflows(*names) ⇒ Object
42 43 44 |
# File 'lib/cellect/server/adapters/default.rb', line 42 def load_workflows(*names) workflow_list(*names).each{ |workflow_info| load_workflow workflow_info } end |
#status ⇒ Object
Report adapter status as a Hash
38 39 40 |
# File 'lib/cellect/server/adapters/default.rb', line 38 def status { } end |
#workflow_for(opts = { }) ⇒ Object
58 59 60 61 62 |
# File 'lib/cellect/server/adapters/default.rb', line 58 def workflow_for(opts = { }) workflow_klass = opts.fetch('grouped', false) ? GroupedWorkflow : Workflow workflow_klass[opts['name']] = opts workflow_klass[opts['name']] end |
#workflow_list(*names) ⇒ Object
Return a list of workflows to load in the form:
[{
'id' => 123,
'name' => 'foo',
'prioritized' => false,
'pairwise' => false,
'grouped' => false
}, ...]
13 14 15 |
# File 'lib/cellect/server/adapters/default.rb', line 13 def workflow_list(*names) raise NotImplementedError end |