Class: DocuSign::Builder::TabBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/docu_sign/builder/tab_builder.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#object

Instance Method Summary collapse

Methods inherited from Base

#builder_class

Constructor Details

#initialize(document = nil, recipient = nil) ⇒ TabBuilder

Returns a new instance of TabBuilder.



8
9
10
11
# File 'lib/docu_sign/builder/tab_builder.rb', line 8

def initialize(document = nil, recipient = nil)
  super
  self.document, self.recipient = document, recipient
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



4
5
6
# File 'lib/docu_sign/builder/tab_builder.rb', line 4

def document
  @document
end

#recipientObject

Returns the value of attribute recipient.



4
5
6
# File 'lib/docu_sign/builder/tab_builder.rb', line 4

def recipient
  @recipient
end

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docu_sign/builder/tab_builder.rb', line 13

def build(options = {}, &block)
  anchor_options = options.delete(:anchor)

  super(options, &block).tap do |tab|
    tab.anchor anchor_options if anchor_options && !tab.anchor_tab_item
    tab.document_id  ||= document.id  if document
    tab.recipient_id ||= recipient.id if recipient

    # Default tab_label to the tab name if none is explicitly given
    tab.tab_label ||= tab.name

    # Provide a custom tab type if none has already been provided
    tab.type ||= "Custom"
  end
end