Class: DocuSign::Tab

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

Constant Summary collapse

ATTRIBUTES =
[:document_id, :recipient_id, :page_number, :x_position, :y_position, :scale_value, :anchor_tab_item,
:type, :name, :tab_label, :value, :custom_tab_type, :custom_tab_width, :custom_tab_height, :custom_tab_required,
:conceal_value_on_document, :custom_tab_locked, :custom_tab_disable_auto_size, :custom_tab_list_items,
:custom_tab_list_values, :custom_tab_list_selected_value, :custom_tab_radio_group_name,
:custom_tab_validation_pattern, :custom_tab_validation_message, :template_locked, :template_required,
:conditional_parent_label, :conditional_parent_value, :shared_tab, :require_initial_on_shared_tab_change,
:font, :bold, :italic, :underline, :font_color, :font_size, :merge_field_xml, :include_note_in_email]

Instance Method Summary collapse

Methods inherited from DocuSignModel

#method_missing

Constructor Details

#initialize(attributes = {}) ⇒ Tab

Returns a new instance of Tab.



18
19
20
21
22
# File 'lib/docu_sign/tab.rb', line 18

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 Method Details

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



24
25
26
27
28
29
# File 'lib/docu_sign/tab.rb', line 24

def anchor(options = {}, &block)
  anchor_builder.build(options, &block).tap do |a|
    yield a if block_given?
    self.anchor_tab_item = a
  end
end

#anchor=(options = {}) ⇒ Object



31
32
33
# File 'lib/docu_sign/tab.rb', line 31

def anchor=(options = {})
  anchor options
end

#anchor_builderObject



35
36
37
# File 'lib/docu_sign/tab.rb', line 35

def anchor_builder
  @anchor_builder ||= DocuSign::Builder::AnchorBuilder.new
end

#to_savonObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/docu_sign/tab.rb', line 47

def to_savon
  {
    "DocumentID" => self.document_id,
    "RecipientID" => self.recipient_id,
    "PageNumber" => self.page_number,
    "XPosition" => self.x_position,
    "YPosition" => self.y_position,
    "ScaleValue" => self.scale_value,
    "AnchorTabItem" => self.anchor_tab_item.try(:to_savon),
    "Type" => self.type,
    "Name" => self.name,
    "TabLabel" => self.tab_label,
    "Value" => self.value,
    "CustomTabType" => self.custom_tab_type,
    "CustomTabWidth" => self.custom_tab_width,
    "CustomTabHeight" => self.custom_tab_height,
    "CustomTabRequired" => self.custom_tab_required?,
    "ConcealValueOnDocument" => self.conceal_value_on_document?,
    "CustomTabLocked" => self.custom_tab_locked?,
    "CustomTabDisableAutoSize" => self.custom_tab_disable_auto_size?,
    "CustomTabListItems" => self.custom_tab_list_items,
    "CustomTabListValues" => self.custom_tab_list_values,
    "CustomTabListSelectedValue" => self.custom_tab_list_selected_value,
    "CustomTabRadioGroupName" => self.custom_tab_radio_group_name,
    "CustomTabValidationPattern" => self.custom_tab_validation_pattern,
    "CustomTabValidationMessage" => self.custom_tab_validation_message,
    "TemplateLocked" => self.template_locked?,
    "TemplateRequired" => self.template_required?,
    "ConditionalParentLabel" => self.conditional_parent_label,
    "ConditionalParentValue" => self.conditional_parent_value,
    "SharedTab" => self.shared_tab?,
    "RequireInitialOnSharedTabChange" => self.require_initial_on_shared_tab_change?,
    "Font" => self.font,
    "Bold" => self.bold,
    "Italic" => self.italic,
    "Underline" => self.underline,
    "FontColor" => self.font_color,
    "FontSize" => self.font_size,
    "MergeFieldXml" => self.merge_field_xml,
    "IncludeNoteInEmail" => self.include_note_in_email?
  }.delete_if{|key, value| value.nil?}
end