Class: Signatory::Template

Inherits:
API::Base
  • Object
show all
Defined in:
lib/signatory/template.rb

Instance Method Summary collapse

Methods inherited from API::Base

all, connection, escape_url_attrs, formatted_collection_name, formatted_name, #has_many, #id, instantiate_collection, #instantiate_record, #persisted?

Instance Method Details

#build_document(merge_fields, roles) ⇒ Object



14
15
16
17
# File 'lib/signatory/template.rb', line 14

def build_document(merge_fields, roles)
  doc_pkg = prepackage
  doc_pkg.prefill_and_send(merge_fields, roles)
end

#prepackageObject



9
10
11
12
# File 'lib/signatory/template.rb', line 9

def prepackage
  record = connection.format.decode(post(:prepackage).body)
  DocumentPackage.send(:instantiate_record, record)
end

#to_xml(opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/signatory/template.rb', line 19

def to_xml(opts = {})
  super(opts.merge(:dasherize => false, :skip_types => true, :except => [:pages, :_type, :redirect_token, :content_type, :size, :tags])) do |b|
    b.tag!(:tags) do
      tags.split(" ").each do |tag|
        b.tag!(:tag) { b.value tag}
      end
    end unless attributes['tags'].blank?
  end
end