Class: SimpleAMS::Document

Inherits:
Object
  • Object
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_optionsObject (readonly)

Returns the value of attribute embedded_options.



4
5
6
# File 'lib/simple_ams/document.rb', line 4

def embedded_options
  @embedded_options
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/simple_ams/document.rb', line 4

def options
  @options
end

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'lib/simple_ams/document.rb', line 4

def resource
  @resource
end

#serializerObject (readonly)

Returns the value of attribute serializer.



4
5
6
# File 'lib/simple_ams/document.rb', line 4

def serializer
  @serializer
end

Instance Method Details

#adapterObject



38
39
40
# File 'lib/simple_ams/document.rb', line 38

def adapter
  @adapter ||= options.adapter
end

#document?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/simple_ams/document.rb', line 70

def document?
  !folder?
end

#embeddedObject



74
75
76
77
78
# File 'lib/simple_ams/document.rb', line 74

def embedded
  return nil unless embedded_options

  @embedded ||= SimpleAMS::Document.new(embedded_options)
end

#fieldsObject



17
18
19
20
21
# File 'lib/simple_ams/document.rb', line 17

def fields
  return @fields if defined?(@fields)
  return @fields = [] if options.fields.empty?
  return @fields ||= self.class::Fields.new(options)
end

#folder?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/simple_ams/document.rb', line 66

def folder?
  @is_folder ||= self.is_a?(self.class::Folder)
end

#formsObject



54
55
56
57
58
# File 'lib/simple_ams/document.rb', line 54

def forms
  return @forms if defined?(@forms)
  return @forms = {} if options.forms.empty?
  return @forms ||= self.class::Forms.new(options)
end

#genericsObject



60
61
62
63
64
# File 'lib/simple_ams/document.rb', line 60

def generics
  return @generics if defined?(@generics)
  return @generics = {} if options.generics.empty?
  return @generics ||= self.class::Generics.new(options)
end


42
43
44
45
46
# File 'lib/simple_ams/document.rb', line 42

def links
  return @links if defined?(@links)
  return @links = {} if options.links.empty?
  return @links ||= self.class::Links.new(options)
end

#metasObject



48
49
50
51
52
# File 'lib/simple_ams/document.rb', line 48

def metas
  return @metas if defined?(@metas)
  return @metas = {} if options.metas.empty?
  return @metas ||= self.class::Metas.new(options)
end

#nameObject



30
31
32
# File 'lib/simple_ams/document.rb', line 30

def name
  @name ||= options.name
end

#primary_idObject



13
14
15
# File 'lib/simple_ams/document.rb', line 13

def primary_id
  @primary_id ||= self.class::PrimaryId.new(options)
end

#relationsObject



23
24
25
26
27
28
# File 'lib/simple_ams/document.rb', line 23

def relations
  return @relations if defined?(@relations)
  return @relations ||= self.class::Relations.new(
    options, options.relations
  )
end

#typeObject



34
35
36
# File 'lib/simple_ams/document.rb', line 34

def type
  @type ||= options.type
end