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
# File 'app/models/orcid/work/xml_renderer.rb', line 10

def initialize(works, options = {})
  self.works = works
  @template = options.fetch(:template) { default_template }
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



15
16
17
# File 'app/models/orcid/work/xml_renderer.rb', line 15

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