Module: Arango::Database::Tasks

Included in:
Arango::Database
Defined in:
lib/arango/database/tasks.rb

Instance Method Summary collapse

Instance Method Details

#all_tasksArray<Arango::Task>

Get all tasks.

Returns:



6
7
8
# File 'lib/arango/database/tasks.rb', line 6

def all_tasks
  Arango::Task.all(database: self)
end

#create_task(id: nil, command:, name: nil, offset: nil, params: nil, period: nil) ⇒ Arango::Task

Create a new task with given id, task is saved to the database. TODO Ruby block

Parameters:

  • (defaults to: nil)
  • The javascript code to execute.

  • (defaults to: nil)

    The task name, optional.

  • (defaults to: nil)

    The number of seconds initial delay, optional.

  • (defaults to: nil)

    Hash of params to pass to the command, optional.

  • (defaults to: nil)

    Number of seconds between executions, optional.

Returns:



19
20
21
# File 'lib/arango/database/tasks.rb', line 19

def create_task(id: nil, command:, name: nil, offset: nil, params: nil, period: nil)
  Arango::Task.new(id: id, command: command, name: name, offset: offset, params: params, period: period, database: self).create
end

#drop_task(id:) ⇒ Boolean Also known as: delete_task, destroy_task

Delete task with given id.

Parameters:

Returns:

  • Returns true if task has been deleted.



53
54
55
# File 'lib/arango/database/tasks.rb', line 53

def drop_task(id:)
  Arango::Task.delete(id: id, database: self)
end

#get_task(id:) ⇒ Arango::Task Also known as: fetch_task, retrieve_task

Get a task from the database.

Parameters:

Returns:



26
27
28
# File 'lib/arango/database/tasks.rb', line 26

def get_task(id:)
  Arango::Task.get(id: id, database: self)
end

#list_tasksArray<String>

Get a list of all task ids.

Returns:



46
47
48
# File 'lib/arango/database/tasks.rb', line 46

def list_tasks
  Arango::Task.list(database: self)
end

#new_task(id: nil, command: nil, name: nil, offset: nil, params: nil, period: nil) ⇒ Arango::Task

Instantiate a new task with given id, task is not saved to the database.

Parameters:

  • (defaults to: nil)
  • (defaults to: nil)

    The javascript code to execute, optional.

  • (defaults to: nil)

    The task name, optional.

  • (defaults to: nil)

    The number of seconds initial delay, optional.

  • (defaults to: nil)

    Hash of params to pass to the command, optional.

  • (defaults to: nil)

    Number of seconds between executions, optional.

Returns:



40
41
42
# File 'lib/arango/database/tasks.rb', line 40

def new_task(id: nil, command: nil, name: nil, offset: nil, params: nil, period: nil)
  Arango::Task.new(id: id, command: command, name: name, offset: offset, params: params, period: period, database: self)
end

#task_exists?(id:) ⇒ Boolean

Checks existence of a task.

Parameters:

Returns:

  • Returns true if the task exists, otherwise false.



62
63
64
# File 'lib/arango/database/tasks.rb', line 62

def task_exists?(id:)
  Arango::Task.exists?(id: id, database: self)
end