Module: MyTodoActions
- Defined in:
- lib/my_todo/modules/my_todo_actions.rb
Instance Method Summary collapse
- #ask_status ⇒ Object
- #assign_detailed_status ⇒ Object
- #create_item(options) ⇒ Object
- #set_default_status ⇒ Object
- #set_tags ⇒ Object
- #update_item(options) ⇒ Object
Instance Method Details
#ask_status ⇒ Object
2 3 4 5 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 2 def ask_status list_statuses @status = ask("Choose a status for item", default: set_default_status) end |
#assign_detailed_status ⇒ Object
21 22 23 24 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 21 def assign_detailed_status ask_status @item.write_attribute(:detailed_status, detailed_statuses[@status.to_i]) end |
#create_item(options) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 7 def create_item() @item = Item.new(.except(:tags)) assign_detailed_status @item.save! end |
#set_default_status ⇒ Object
30 31 32 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 30 def set_default_status @item.detailed_status.nil? ? 1 : detailed_statuses.index(@item.detailed_status) end |
#set_tags ⇒ Object
26 27 28 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 26 def [:tags].split(' ').each{|tag| @item..create(name: tag) } if [:tags] end |
#update_item(options) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/my_todo/modules/my_todo_actions.rb', line 14 def update_item() item.assign_attributes() @item = item #Find a better way!!!! assign_detailed_status item.save! end |