Class: DocuSign::Document

Inherits:
DocuSignModel show all
Defined in:
lib/docu_sign/document.rb

Constant Summary collapse

ATTRIBUTES =
[:tabs, :id, :name, :pdf_bytes, :password, :transform_pdf_fields, :file_extension, :match_boxes,
:attachment_description]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DocuSignModel

#method_missing

Constructor Details

#initialize(attributes = {}) ⇒ Document

Returns a new instance of Document.



10
11
12
13
14
# File 'lib/docu_sign/document.rb', line 10

def initialize(attributes = {})
  ATTRIBUTES.each do |attr|
    self.send("#{attr}=", attributes[attr])
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DocuSign::DocuSignModel

Instance Attribute Details

#tab_builderObject



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

def tab_builder
  @tab_builder ||= DocuSign::Builder::TabBuilder.new(self)
end

Instance Method Details

#tab(options = {}, &block) ⇒ Object



28
29
30
31
32
# File 'lib/docu_sign/document.rb', line 28

def tab(options = {}, &block)
  tab_builder.build(options, &block).tap do |t|
    tabs << t
  end
end

#tabs(recipient = nil, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/docu_sign/document.rb', line 16

def tabs(recipient = nil, &block)
  @tabs ||= DocuSign::ArrayOfTab.new

  return @tabs unless block_given?

  self.tab_builder = DocuSign::Builder::TabBuilder.new(self, recipient)

  @tabs.tap do |a|
    yield self if block_given?
  end
end

#to_savonObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/docu_sign/document.rb', line 38

def to_savon
  {
    "ID" => self.id,
    "Name" => self.name,
    "PDFBytes" => self.pdf_bytes,
    "Password" => self.password,
    "TransformPdfFields" => self.transform_pdf_fields,
    "FileExtension" => self.file_extension,
    "MatchBoxes" => self.match_boxes,
    "AttachmentDescription" => self.attachment_description
  }.delete_if{|key, value| value.nil?}
end