Class: ProjectFromTodo
- Inherits:
-
Object
- Object
- ProjectFromTodo
- Defined in:
- lib/project_from_todo.rb
Instance Attribute Summary collapse
-
#todo ⇒ Object
readonly
Returns the value of attribute todo.
Instance Method Summary collapse
- #build_project ⇒ Object
- #create ⇒ Object
-
#initialize(todo) ⇒ ProjectFromTodo
constructor
A new instance of ProjectFromTodo.
Constructor Details
#initialize(todo) ⇒ ProjectFromTodo
Returns a new instance of ProjectFromTodo.
4 5 6 |
# File 'lib/project_from_todo.rb', line 4 def initialize(todo) @todo = todo end |
Instance Attribute Details
#todo ⇒ Object (readonly)
Returns the value of attribute todo.
2 3 4 |
# File 'lib/project_from_todo.rb', line 2 def todo @todo end |
Instance Method Details
#build_project ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/project_from_todo.rb', line 19 def build_project project = Project.new.tap do |p| p.name = todo.description p.description = todo.notes p.default_context = todo.context p. = todo.tag_list p.user = todo.user end end |
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/project_from_todo.rb', line 8 def create project = build_project if project.valid? todo.destroy project.save! end project end |