Class: Orcid::Work::XmlRenderer
- Inherits:
-
Object
- Object
- Orcid::Work::XmlRenderer
- Defined in:
- app/models/orcid/work/xml_renderer.rb
Overview
Responsible for transforming a Work into an Orcid Work XML document
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#works ⇒ Object
readonly
Returns the value of attribute works.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(works, options = {}) ⇒ XmlRenderer
constructor
A new instance of XmlRenderer.
Constructor Details
#initialize(works, options = {}) ⇒ XmlRenderer
Returns a new instance of XmlRenderer.
10 11 12 13 14 15 16 |
# File 'app/models/orcid/work/xml_renderer.rb', line 10 def initialize(works, = {}) self.works = works @template = .fetch(:template_path) do template_name = 'app/templates/orcid/work.template.v1.1.xml.erb' Orcid::Engine.root.join(template_name).read end end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
9 10 11 |
# File 'app/models/orcid/work/xml_renderer.rb', line 9 def template @template end |
#works ⇒ Object
Returns the value of attribute works.
9 10 11 |
# File 'app/models/orcid/work/xml_renderer.rb', line 9 def works @works end |
Class Method Details
.call(works, options = {}) ⇒ Object
5 6 7 |
# File 'app/models/orcid/work/xml_renderer.rb', line 5 def self.call(works, = {}) new(works, ).call end |
Instance Method Details
#call ⇒ Object
18 19 20 |
# File 'app/models/orcid/work/xml_renderer.rb', line 18 def call ERB.new(template).result(binding) end |