Class: Jahuty::Resource::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/jahuty/resource/render.rb

Overview

A snippet’s rendered content.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, snippet_id:) ⇒ Render

Returns a new instance of Render.



9
10
11
12
# File 'lib/jahuty/resource/render.rb', line 9

def initialize(content:, snippet_id:)
  @content = content
  @snippet_id = snippet_id
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/jahuty/resource/render.rb', line 7

def content
  @content
end

#snippet_idObject

Returns the value of attribute snippet_id.



7
8
9
# File 'lib/jahuty/resource/render.rb', line 7

def snippet_id
  @snippet_id
end

Class Method Details

.from(data) ⇒ Object

Raises:

  • (ArgumentError.new)


14
15
16
17
18
19
# File 'lib/jahuty/resource/render.rb', line 14

def self.from(data)
  raise ArgumentError.new, 'Key :content missing' unless data.key?(:content)
  raise ArgumentError.new, 'Key :snippet_id missing' unless data.key?(:snippet_id)

  Render.new(**data.slice(:content, :snippet_id))
end

Instance Method Details

#to_sObject



21
22
23
# File 'lib/jahuty/resource/render.rb', line 21

def to_s
  @content
end