Class: MoveToGo::Todo
- Inherits:
-
CanBecomeImmutable
- Object
- CanBecomeImmutable
- MoveToGo::Todo
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/todo.rb
Instance Attribute Summary collapse
-
#assigned_coworker ⇒ Object
Returns the value of attribute assigned_coworker.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#date_checked ⇒ Object
Returns the value of attribute date_checked.
-
#date_start ⇒ Object
Returns the value of attribute date_start.
-
#date_start_has_time ⇒ Object
Returns the value of attribute date_start_has_time.
-
#deal ⇒ Object
Returns the value of attribute deal.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#person ⇒ Object
Returns the value of attribute person.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #get_import_rows ⇒ Object
-
#id ⇒ Object
:attr_accessor: id.
-
#initialize(opt = nil) ⇒ Todo
constructor
A new instance of Todo.
-
#integration_id ⇒ Object
:attr_accessor: integration_id.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #validate ⇒ Object
Methods included from SerializeHelper
#serialize, #serialize_to_file
Methods inherited from CanBecomeImmutable
immutable_accessor, #is_immutable, #raise_if_immutable, #set_is_immutable
Constructor Details
#initialize(opt = nil) ⇒ Todo
Returns a new instance of Todo.
15 16 17 18 19 20 21 22 |
# File 'lib/move-to-go/model/todo.rb', line 15 def initialize(opt = nil) if !opt.nil? serialize_variables.each do |myattr| val = opt[myattr[:id]] instance_variable_set("@" + myattr[:id].to_s, val) if val != nil end end end |
Instance Attribute Details
#assigned_coworker ⇒ Object
Returns the value of attribute assigned_coworker.
13 14 15 |
# File 'lib/move-to-go/model/todo.rb', line 13 def assigned_coworker @assigned_coworker end |
#created_by ⇒ Object
Returns the value of attribute created_by.
13 14 15 |
# File 'lib/move-to-go/model/todo.rb', line 13 def created_by @created_by end |
#date_checked ⇒ Object
Returns the value of attribute date_checked.
12 13 14 |
# File 'lib/move-to-go/model/todo.rb', line 12 def date_checked @date_checked end |
#date_start ⇒ Object
Returns the value of attribute date_start.
12 13 14 |
# File 'lib/move-to-go/model/todo.rb', line 12 def date_start @date_start end |
#date_start_has_time ⇒ Object
Returns the value of attribute date_start_has_time.
12 13 14 |
# File 'lib/move-to-go/model/todo.rb', line 12 def date_start_has_time @date_start_has_time end |
#deal ⇒ Object
Returns the value of attribute deal.
13 14 15 |
# File 'lib/move-to-go/model/todo.rb', line 13 def deal @deal end |
#organization ⇒ Object
Returns the value of attribute organization.
13 14 15 |
# File 'lib/move-to-go/model/todo.rb', line 13 def organization @organization end |
#person ⇒ Object
Returns the value of attribute person.
13 14 15 |
# File 'lib/move-to-go/model/todo.rb', line 13 def person @person end |
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/move-to-go/model/todo.rb', line 11 def text @text end |
Instance Method Details
#get_import_rows ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/move-to-go/model/todo.rb', line 43 def get_import_rows (serialize_variables + [ { :id => :organization, :type => :organization_reference}, { :id => :person, :type => :person_reference} ]).map do |p| map_to_row p end end |
#id ⇒ Object
:attr_accessor: id
6 |
# File 'lib/move-to-go/model/todo.rb', line 6 immutable_accessor :id |
#integration_id ⇒ Object
:attr_accessor: integration_id
9 |
# File 'lib/move-to-go/model/todo.rb', line 9 immutable_accessor :integration_id |
#serialize_name ⇒ Object
52 53 54 |
# File 'lib/move-to-go/model/todo.rb', line 52 def serialize_name "Todo" end |
#serialize_variables ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/move-to-go/model/todo.rb', line 24 def serialize_variables [ :id, :text, :integration_id ].map { |p| { :id => p, :type => :string } } + [ { :id => :date_start, :type => :datetime }, { :id => :date_start_has_time, :type => :bool }, { :id => :date_checked, :type => :datetime }, { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by }, { :id => :assigned_coworker_reference, :type => :coworker_reference, :element_name => :assigned_coworker }, { :id => :organization_reference, :type => :organization_reference, :element_name => :organization }, { :id => :deal_reference, :type => :deal_reference, :element_name => :deal }, { :id => :person_reference, :type => :person_reference, :element_name => :person } ] end |
#validate ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/move-to-go/model/todo.rb', line 152 def validate error = String.new if (@text.nil? || @text.empty?) error = "Text is required for todo\n" end if @created_by.nil? error = "#{error}Created_by is required for todo\n" end if @assigned_coworker_reference.nil? error = "#{error}Assigned_coworker is required for todo\n" end if @date_start.nil? error = "#{error}Date_start is required for todo\n" end if @date_start_has_time.nil? error = "#{error}Date_start_has_time is required for todo\n" end if @organization.nil? error = "#{error}Organization is required for todo\n" end return error end |