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
# 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
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



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

def blocks
  @blocks
end

#overridesObject (readonly)

Returns the value of attribute overrides.



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

def overrides
  @overrides
end

Instance Method Details

#rootObject



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

def root
  self
end