lib/pdfmonkey/document.rb in pdfmonkey-0.2.0 vs lib/pdfmonkey/document.rb in pdfmonkey-0.3.0

- old
+ new

@@ -30,11 +30,11 @@ attr_reader :attributes def_delegators :attributes, *ATTRIBUTES def self.generate!(document_template_id, payload) document = generate(document_template_id, payload) - document.reload! until COMPLETE_STATUSES.include?(document.status) + document.reload! until document.done? document end def self.generate(template_id, payload) document = new( @@ -47,9 +47,13 @@ def initialize(adapter: Pdfmonkey::Adapter.new, **attributes) @adapter = adapter @attributes = OpenStruct.new(ATTRIBUTES.zip([]).to_h) update(attributes) + end + + def done? + COMPLETE_STATUSES.include?(status) end def reload! attributes = adapter.call(:get, self) update(attributes)