Class: MoveToGo::Link
- Inherits:
-
Object
- Object
- MoveToGo::Link
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/link.rb
Instance Attribute Summary collapse
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#deal ⇒ Object
Returns the value of attribute deal.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#person ⇒ Object
Returns the value of attribute person.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(opt = nil) ⇒ Link
constructor
A new instance of Link.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #validate ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ Link
Returns a new instance of Link.
8 9 10 11 12 13 14 15 |
# File 'lib/move-to-go/model/link.rb', line 8 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
#created_by ⇒ Object
Returns the value of attribute created_by.
6 7 8 |
# File 'lib/move-to-go/model/link.rb', line 6 def created_by @created_by end |
#deal ⇒ Object
Returns the value of attribute deal.
6 7 8 |
# File 'lib/move-to-go/model/link.rb', line 6 def deal @deal end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/move-to-go/model/link.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/move-to-go/model/link.rb', line 4 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
4 5 6 |
# File 'lib/move-to-go/model/link.rb', line 4 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/move-to-go/model/link.rb', line 4 def name @name end |
#organization ⇒ Object
Returns the value of attribute organization.
6 7 8 |
# File 'lib/move-to-go/model/link.rb', line 6 def organization @organization end |
#person ⇒ Object
Returns the value of attribute person.
6 7 8 |
# File 'lib/move-to-go/model/link.rb', line 6 def person @person end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/move-to-go/model/link.rb', line 4 def url @url end |
Instance Method Details
#serialize_name ⇒ Object
17 18 19 |
# File 'lib/move-to-go/model/link.rb', line 17 def serialize_name "Link" end |
#serialize_variables ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/move-to-go/model/link.rb', line 21 def serialize_variables [ :id, :integration_id, :url, :name, :description ].map { |p| { :id => p, :type => :string } } + [ { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by }, { :id => :organization_reference, :type => :organization_reference, :element_name => :organization }, { :id => :person_reference, :type => :person_reference, :element_name => :person }, { :id => :deal_reference, :type => :deal_reference, :element_name => :deal } ] end |
#validate ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/move-to-go/model/link.rb', line 68 def validate error = String.new if @url.nil? || @url.empty? error = "Url is required for link\n" end if @created_by_reference.nil? error = "#{error}Created_by is required for link\n" end if @organization_reference.nil? && @deal_reference.nil? && @person_reference.nil? error = "#{error}A link must have either an organization, person or a deal\n" end return error end |