Class: SimpleAMS::Document
- Inherits:
-
Object
- Object
- SimpleAMS::Document
show all
- Defined in:
- lib/simple_ams/document.rb
Direct Known Subclasses
Folder
Defined Under Namespace
Classes: Fields, Folder, Forms, Generics, Links, Metas, PrimaryId, Relations
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options, embedded_options = nil) ⇒ Document
Returns a new instance of Document.
6
7
8
9
10
11
|
# File 'lib/simple_ams/document.rb', line 6
def initialize(options, embedded_options = nil)
@options = options
@embedded_options = embedded_options
@serializer = options.serializer
@resource = options.resource
end
|
Instance Attribute Details
#embedded_options ⇒ Object
Returns the value of attribute embedded_options.
4
5
6
|
# File 'lib/simple_ams/document.rb', line 4
def embedded_options
@embedded_options
end
|
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/simple_ams/document.rb', line 4
def options
@options
end
|
#resource ⇒ Object
Returns the value of attribute resource.
4
5
6
|
# File 'lib/simple_ams/document.rb', line 4
def resource
@resource
end
|
#serializer ⇒ Object
Returns the value of attribute serializer.
4
5
6
|
# File 'lib/simple_ams/document.rb', line 4
def serializer
@serializer
end
|
Instance Method Details
#adapter ⇒ Object
40
41
42
|
# File 'lib/simple_ams/document.rb', line 40
def adapter
@adapter ||= options.adapter
end
|
#document? ⇒ Boolean
rubocop:enable Naming/MemoizedInstanceVariableName
78
79
80
|
# File 'lib/simple_ams/document.rb', line 78
def document?
!folder?
end
|
#embedded ⇒ Object
82
83
84
85
86
|
# File 'lib/simple_ams/document.rb', line 82
def embedded
return nil unless embedded_options
@embedded ||= SimpleAMS::Document.new(embedded_options)
end
|
#fields ⇒ Object
17
18
19
20
21
22
|
# File 'lib/simple_ams/document.rb', line 17
def fields
return @fields if defined?(@fields)
return @fields = [] if options.fields.empty?
@fields ||= self.class::Fields.new(options)
end
|
#folder? ⇒ Boolean
rubocop:disable Naming/MemoizedInstanceVariableName
73
74
75
|
# File 'lib/simple_ams/document.rb', line 73
def folder?
@is_folder ||= is_a?(self.class::Folder)
end
|
58
59
60
61
62
63
|
# File 'lib/simple_ams/document.rb', line 58
def forms
return @forms if defined?(@forms)
return @forms = {} if options.forms.empty?
@forms ||= self.class::Forms.new(options)
end
|
#generics ⇒ Object
65
66
67
68
69
70
|
# File 'lib/simple_ams/document.rb', line 65
def generics
return @generics if defined?(@generics)
return @generics = {} if options.generics.empty?
@generics ||= self.class::Generics.new(options)
end
|
#links ⇒ Object
44
45
46
47
48
49
|
# File 'lib/simple_ams/document.rb', line 44
def links
return @links if defined?(@links)
return @links = {} if options.links.empty?
@links ||= self.class::Links.new(options)
end
|
51
52
53
54
55
56
|
# File 'lib/simple_ams/document.rb', line 51
def metas
return @metas if defined?(@metas)
return @metas = {} if options.metas.empty?
@metas ||= self.class::Metas.new(options)
end
|
#name ⇒ Object
32
33
34
|
# File 'lib/simple_ams/document.rb', line 32
def name
@name ||= options.name
end
|
#primary_id ⇒ Object
13
14
15
|
# File 'lib/simple_ams/document.rb', line 13
def primary_id
@primary_id ||= self.class::PrimaryId.new(options)
end
|
#relations ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/simple_ams/document.rb', line 24
def relations
return @relations if defined?(@relations)
@relations ||= self.class::Relations.new(
options, options.relations
)
end
|
#type ⇒ Object
36
37
38
|
# File 'lib/simple_ams/document.rb', line 36
def type
@type ||= options.type
end
|