my_todo 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70b1f135ecffdf6707b18aa7a916493221bce327
4
- data.tar.gz: e8fcb736c11ac62879afdc96b33f2f98a23f3875
3
+ metadata.gz: b4c70de321e879cf5515fbbd10b78e71f8a69017
4
+ data.tar.gz: 53acd0ce0b42fe4cd6baf3bfbadd7c272350c739
5
5
  SHA512:
6
- metadata.gz: 01ec4a1b26546905b02194a39d4ccd84f9b74defdb49046183ea9ef06cc129f9a7100148ab105d72744f05bc79b9256ae1a8a8fe1c320a9f030ce3cb7504ec68
7
- data.tar.gz: a6887b4de5c89b24e7e56ce2910941f9824658f7f27939081f3f03412a72271510f2f712cd636087daee721c8fdd4332c073e1495607a27d719f14fdc2fd0055
6
+ metadata.gz: 811c02060a4a567ba1528c55152f40d4075387fee2c3d09f810ea685a9f6f577082fabb4f9af87869ad90338d6d880edafb74eac937ba57e58bb409c8f4a21d6
7
+ data.tar.gz: cd090f60fd4879456d9ce52e3939d8dd344c5e8acaff04e21a41cee1a8f94b01044d02241f7adc54d43388ebeadb809934001f58ed7146d4ef8176cf092f5ea9
Binary file
@@ -21,6 +21,8 @@ class Item < ActiveRecord::Base
21
21
  # ActiveModel validation to ensure body is present
22
22
  validates :body, presence: true
23
23
 
24
+ # Hook to set done boolean based on detailed status
25
+ #(see #update_done)
24
26
  before_save :update_done
25
27
 
26
28
  #set done attribute based on detailed_status set
@@ -1,18 +1,33 @@
1
1
  module MyTodoActions
2
2
  def ask_status
3
3
  list_statuses
4
- @status = ask("Choose a status for item", default: 1)
4
+ @status = ask("Choose a status for item", default: set_default_status)
5
5
  end
6
6
 
7
7
  def create_item(options)
8
- ask_status
9
- @item = Item.create!(options.merge({detailed_status: detailed_statuses[@status.to_i]}).except(:tags))
10
- options[:tags].split(' ').each{|tag| item.tags.create(name: tag) } if options[:tags]
8
+ @item = Item.new(options.except(:tags))
9
+ assign_detailed_status
10
+ @item.save!
11
+ set_tags
11
12
  end
12
13
 
13
14
  def update_item(options)
15
+ item.assign_attributes(options)
16
+ @item = item #Find a better way!!!!
17
+ assign_detailed_status
18
+ item.save!
19
+ end
20
+
21
+ def assign_detailed_status
14
22
  ask_status
15
- new_status = detailed_statuses[@status.to_i]
16
- item.detailed_status != new_status ? item.update!(options.merge({detailed_status: new_status})) : item.update!(options)
23
+ @item.write_attribute(:detailed_status, detailed_statuses[@status.to_i])
24
+ end
25
+
26
+ def set_tags
27
+ options[:tags].split(' ').each{|tag| @item.tags.create(name: tag) } if options[:tags]
28
+ end
29
+
30
+ def set_default_status
31
+ @item.detailed_status.nil? ? 1 : detailed_statuses.index(@item.detailed_status)
17
32
  end
18
33
  end
@@ -1,3 +1,3 @@
1
1
  module MyTodo
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler