Class: FruitToLime::Note
- Inherits:
-
Object
- Object
- FruitToLime::Note
- Includes:
- SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/note.rb
Instance Attribute Summary collapse
-
#classification ⇒ Object
The note’s classification.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#date ⇒ Object
Returns the value of attribute date.
-
#deal ⇒ Object
Returns the value of attribute deal.
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#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
-
#initialize(opt = nil) ⇒ Note
constructor
A new instance of Note.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #validate ⇒ Object
Methods included from SerializeHelper
#serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ Note
Returns a new instance of Note.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fruit_to_lime/model/note.rb', line 12 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 @classification = NoteClassification::Comment if @classification.nil? end |
Instance Attribute Details
#classification ⇒ Object
The note’s classification. It should be a value from #NoteClassification. The default value is Comment.
10 11 12 |
# File 'lib/fruit_to_lime/model/note.rb', line 10 def classification @classification end |
#created_by ⇒ Object
Returns the value of attribute created_by.
6 7 8 |
# File 'lib/fruit_to_lime/model/note.rb', line 6 def created_by @created_by end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/fruit_to_lime/model/note.rb', line 4 def date @date end |
#deal ⇒ Object
Returns the value of attribute deal.
6 7 8 |
# File 'lib/fruit_to_lime/model/note.rb', line 6 def deal @deal end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/fruit_to_lime/model/note.rb', line 4 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
4 5 6 |
# File 'lib/fruit_to_lime/model/note.rb', line 4 def integration_id @integration_id end |
#organization ⇒ Object
Returns the value of attribute organization.
6 7 8 |
# File 'lib/fruit_to_lime/model/note.rb', line 6 def organization @organization end |
#person ⇒ Object
Returns the value of attribute person.
6 7 8 |
# File 'lib/fruit_to_lime/model/note.rb', line 6 def person @person end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/fruit_to_lime/model/note.rb', line 4 def text @text end |
Instance Method Details
#get_import_rows ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/fruit_to_lime/model/note.rb', line 39 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 |
#serialize_name ⇒ Object
48 49 50 |
# File 'lib/fruit_to_lime/model/note.rb', line 48 def serialize_name "Note" end |
#serialize_variables ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fruit_to_lime/model/note.rb', line 23 def serialize_variables [ :id, :text, :integration_id, :classification ].map { |p| { :id => p, :type => :string } } + [ { :id => :date, :type => :date }, { :id => :created_by, :type => :coworker_reference }, { :id => :organization, :type => :organization_reference }, { :id => :deal, :type => :deal_reference }, { :id => :person, :type => :person_reference } ] end |
#validate ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fruit_to_lime/model/note.rb', line 79 def validate error = String.new if @text.nil? || @text.empty? error = "Text is required for note\n" end if @created_by.nil? error = "#{error}Created_by is required for note\n" end if @organization.nil? && @deal.nil? && @person.nil? error = "#{error}Organization, deal or person is required for note\n" end return error end |