Sha256: 12b88af9852df25143699376a4e7e3e369eee58346bfa3a0715713fe41956b38

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

module DocuSign
  module Builder
    class TabBuilder < DocuSign::Builder::Base
      attr_accessor :document, :recipient

      self.builder_class = DocuSign::Tab

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

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
docu_sign-0.0.6 lib/docu_sign/builder/tab_builder.rb
docu_sign-0.0.5 lib/docu_sign/builder/tab_builder.rb
docu_sign-0.0.4 lib/docu_sign/builder/tab_builder.rb
docu_sign-0.0.3 lib/docu_sign/builder/tab_builder.rb