Class: DocContract::ContractInstance
Constant Summary
collapse
- RANSACKABLE_ATTRIBUTES =
%w[name].freeze
- RANSACKABLE_ASSOCIATIONS =
%w[contract_template].freeze
Instance Method Summary
collapse
ransackable_associations, ransackable_attributes
Instance Method Details
#config ⇒ Object
13
14
15
16
|
# File 'app/models/doc_contract/contract_instance.rb', line 13
def config
own_config = YAML.safe_load(config_yml.to_s, permitted_classes: [Symbol, Date]) || {}
own_config.reverse_merge contract_template.config
end
|
#markdown ⇒ Object
18
19
20
|
# File 'app/models/doc_contract/contract_instance.rb', line 18
def markdown
contract_template.markdown
end
|
#markdown=(value) ⇒ Object
22
23
24
|
# File 'app/models/doc_contract/contract_instance.rb', line 22
def markdown=(value)
contract_template.markdown = value
end
|
#processed_html ⇒ Object
40
41
42
43
44
|
# File 'app/models/doc_contract/contract_instance.rb', line 40
def processed_html
result = processed_markdown.sub(/.*\n...\n\n/m, '')
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, tables: true)
markdown.render result
end
|
#processed_markdown(config_addittions = {}) ⇒ Object
26
27
28
29
30
|
# File 'app/models/doc_contract/contract_instance.rb', line 26
def processed_markdown(config_addittions = {})
config = self.config
config.merge! config_addittions unless config_addittions.blank?
DocContract::Handlebars.compile(markdown, config)
end
|
#template_markdown(config_addittions = {}) ⇒ Object
32
33
34
35
36
37
38
|
# File 'app/models/doc_contract/contract_instance.rb', line 32
def template_markdown(config_addittions = {})
config = self.config
config.merge! config_addittions unless config_addittions.blank?
result = DocContract::Handlebars.compile(markdown, config)
"#{config.to_yaml}...\n\n#{result}"
end
|