Class: MoveToGo::Documents
- Inherits:
-
Object
- Object
- MoveToGo::Documents
show all
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/documents.rb
Overview
This class is the container for all documents, ie links and
files.
Instance Attribute Summary collapse
Instance Method Summary
collapse
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
Returns a new instance of Documents.
21
22
23
24
|
# File 'lib/move-to-go/model/documents.rb', line 21
def initialize
@links = []
@files = []
end
|
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
8
9
10
|
# File 'lib/move-to-go/model/documents.rb', line 8
def files
@files
end
|
#links ⇒ Object
Returns the value of attribute links.
8
9
10
|
# File 'lib/move-to-go/model/documents.rb', line 8
def links
@links
end
|
Instance Method Details
#add_file(file) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/move-to-go/model/documents.rb', line 51
def add_file(file)
@files = [] if @files == nil
if file.nil?
return nil
end
file = File.new(file) if !file.is_a?(File)
if (!file.integration_id.nil? && file.integration_id.length > 0) &&
find_file_by_integration_id(file.integration_id) != nil
raise AlreadyAddedError, "Already added a file with integration_id '#{file.integration_id}'."
end
@files.push file
return file
end
|
#add_link(link) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/move-to-go/model/documents.rb', line 26
def add_link(link)
@links = [] if @links == nil
if link.nil?
return nil
end
link = Link.new(link) if !link.is_a?(Link)
if (!link.integration_id.nil? && link.integration_id.length > 0) &&
find_link_by_integration_id(link.integration_id) != nil
raise AlreadyAddedError, "Already added a link with integration_id '#{link.integration_id}'."
end
@links.push link
return link
end
|
#find_file_by_integration_id(integration_id) ⇒ Object
70
71
72
73
74
|
# File 'lib/move-to-go/model/documents.rb', line 70
def find_file_by_integration_id(integration_id)
return @files.find do |file|
file.integration_id == integration_id
end
end
|
#find_link_by_integration_id(integration_id) ⇒ Object
45
46
47
48
49
|
# File 'lib/move-to-go/model/documents.rb', line 45
def find_link_by_integration_id(integration_id)
return @links.find do |link|
link.integration_id == integration_id
end
end
|
#serialize_name ⇒ Object
17
18
19
|
# File 'lib/move-to-go/model/documents.rb', line 17
def serialize_name
"Documents"
end
|
#serialize_variables ⇒ Object
10
11
12
13
14
15
|
# File 'lib/move-to-go/model/documents.rb', line 10
def serialize_variables
[
{:id => :links, @type => :links},
{:id => :files, @type => :files}
]
end
|