Module: Task::Task::ClassMethods
- Defined in:
- lib/task/task.rb
Instance Method Summary collapse
-
#build(options) ⇒ Object
Instantiate an instance of this Task subclass.
-
#create(options) ⇒ Object
Instantiate an instance of this Task subclass and save it to the datastore.
-
#data_attr_reader(attr_name) ⇒ Object
Defines an attr reader instance method for a field in the data hash.
Instance Method Details
#build(options) ⇒ Object
Instantiate an instance of this Task subclass.
63 64 65 66 67 |
# File 'lib/task/task.rb', line 63 def build() task_list = .delete(:task_list) id = .delete(:id) || SecureRandom.hex new(task_list: task_list, id: id, data: ) end |
#create(options) ⇒ Object
Instantiate an instance of this Task subclass and save it to the datastore.
74 75 76 77 78 |
# File 'lib/task/task.rb', line 74 def create() task = build() task.save task end |
#data_attr_reader(attr_name) ⇒ Object
Defines an attr reader instance method for a field in the data hash.
89 90 91 |
# File 'lib/task/task.rb', line 89 def data_attr_reader(attr_name) define_method(attr_name) { data[attr_name] } end |