Class: SimpleAMS::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_ams/renderer.rb

Defined Under Namespace

Classes: Collection

Instance Method Summary collapse

Constructor Details

#initialize(resource, options = {}) ⇒ Renderer

Returns a new instance of Renderer.



4
5
6
7
# File 'lib/simple_ams/renderer.rb', line 4

def initialize(resource, options = {})
  @resource = resource
  @options = SimpleAMS::Options.new(resource, injected_options: options)
end

Instance Method Details

#as_jsonObject



18
19
20
# File 'lib/simple_ams/renderer.rb', line 18

def as_json
  options.adapter.klass.new(document, options.adapter.options).as_json
end

#documentObject

resource decorator ?



10
11
12
# File 'lib/simple_ams/renderer.rb', line 10

def document
  @document ||= SimpleAMS::Document.new(options)
end

#nameObject



14
15
16
# File 'lib/simple_ams/renderer.rb', line 14

def name
  @options.name
end

#to_json(*_args) ⇒ Object



22
23
24
# File 'lib/simple_ams/renderer.rb', line 22

def to_json(*_args)
  as_json.to_json
end