Class: Task::DataInterface::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/task/data_interface/interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Interface

Returns a new instance of Interface.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :adapter (#store, #all, #find, #delete)

    adapter to use. Otherwise, the configured adapter builder will be used



22
23
24
# File 'lib/task/data_interface/interface.rb', line 22

def initialize(options = {})
  @adapter = options[:adapter] || self.class.adapter_builder.call(options)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



7
8
9
# File 'lib/task/data_interface/interface.rb', line 7

def adapter
  @adapter
end

Instance Method Details

#all(task_list) ⇒ Enumerator::Lazy<Task::Task>

Returns all tasks for the provided task list

Parameters:

  • task_list (String)

Returns:



34
35
36
# File 'lib/task/data_interface/interface.rb', line 34

def all(task_list)
  adapter.all(task_list)
end

#delete(task_list, task_id) ⇒ Object

Deletes the task with the given id.

Parameters:

  • task_list (String)
  • task_id (String)


49
50
51
# File 'lib/task/data_interface/interface.rb', line 49

def delete(task_list, task_id)
  adapter.delete(task_list, task_id)
end

#find(task_list, task_id) ⇒ Task::Task|NilClass

Returns the task with the given id

Parameters:

  • task_list (String)
  • task_id (String)

Returns:



42
43
44
# File 'lib/task/data_interface/interface.rb', line 42

def find(task_list, task_id)
  adapter.find(task_list, task_id)
end

#store(task) ⇒ Object

Stores a task in the data store

Parameters:



27
28
29
# File 'lib/task/data_interface/interface.rb', line 27

def store(task)
  adapter.store(task)
end