Class: Orcid::Work::XmlRenderer

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  self.works = works
  @template = options.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

#templateObject (readonly)

Returns the value of attribute template.



9
10
11
# File 'app/models/orcid/work/xml_renderer.rb', line 9

def template
  @template
end

#worksObject

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, options = {})
  new(works, options).call
end

Instance Method Details

#callObject



18
19
20
# File 'app/models/orcid/work/xml_renderer.rb', line 18

def call
  ERB.new(template).result(binding)
end