Initial commit
This commit is contained in:
29
app/models/contract_template_preview.rb
Normal file
29
app/models/contract_template_preview.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ContractTemplatePreview
|
||||
def initialize(contract_template)
|
||||
@contract_template = contract_template
|
||||
end
|
||||
|
||||
def build_releasable
|
||||
template_release_type = @contract_template.release_type
|
||||
fill_ct_empty_fields_with_dummy_data
|
||||
releasable = "#{template_release_type}_release".classify.safe_constantize.new
|
||||
releasable.fill_with_dummy_data(@contract_template)
|
||||
releasable
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fill_ct_empty_fields_with_dummy_data
|
||||
if @contract_template.name.blank?
|
||||
@contract_template.name = 'Contract Template Name'
|
||||
end
|
||||
if @contract_template.body.blank?
|
||||
@contract_template.body = 'Contract Template Body text goes here'
|
||||
end
|
||||
if @contract_template.guardian_clause.blank?
|
||||
@contract_template.guardian_clause = 'Contract Template Guardian Clause text goes here'
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user