Class: Dato::StructuredText

Inherits:
Node
  • Object
show all
Defined in:
app/components/dato/structured_text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#debug_node, #render_node

Constructor Details

#initialize(structured_text_node, overrides: {}) ⇒ StructuredText

Returns a new instance of StructuredText.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/dato/structured_text.rb', line 4

def initialize(structured_text_node, overrides: {})
  unless structured_text_node.is_a?(Hashie::Mash)
    raise ArgumentError.new("The parameter is not an instance of Hashie::Mash")
  end

  unless structured_text_node.value.schema == "dast"
    raise ArgumentError.new("The node schema is '#{structured_text_node.value.schema}' instead of 'dast'")
  end

  @overrides = overrides.with_indifferent_access
  @structured_text_node = structured_text_node
  @blocks = structured_text_node.blocks
  @links = structured_text_node.links
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



23
24
25
# File 'app/components/dato/structured_text.rb', line 23

def blocks
  @blocks
end

Returns the value of attribute links.



24
25
26
# File 'app/components/dato/structured_text.rb', line 24

def links
  @links
end

#overridesObject (readonly)

Returns the value of attribute overrides.



26
27
28
# File 'app/components/dato/structured_text.rb', line 26

def overrides
  @overrides
end

Instance Method Details

#rootObject



19
20
21
# File 'app/components/dato/structured_text.rb', line 19

def root
  self
end