module Task::Task::ClassMethods
Public Instance Methods
build(options)
click to toggle source
Instantiate an instance of this Task
subclass. @param options [Hash] Options to instantiate this Task
. :task_list and :id are required;
other arguments will be passed as data to the task.
@option options [String] :task_list @option options [String] :id
# File lib/task/task.rb, line 63 def build(options) task_list = options.delete(:task_list) id = options.delete(:id) || SecureRandom.hex new(task_list: task_list, id: id, data: options) end
create(options)
click to toggle source
Instantiate an instance of this Task
subclass and save it to the datastore. @param options [Hash] Options to instantiate this Task
. :task_list and :id are required;
other arguments will be passed as data to the task.
@option options [String] :task_list @option options [String] :id
# File lib/task/task.rb, line 74 def create(options) task = build(options) task.save task end
data_attr_reader(attr_name)
click to toggle source
Defines an attr reader instance method for a field in the data hash.
@example
class MyTask include Task::Task data_attr_reader :my_data_field end
@param attr_name [Symbol] The attr name of the data field which will be used.
# File lib/task/task.rb, line 89 def data_attr_reader(attr_name) define_method(attr_name) { data[attr_name] } end