Class: Formalist::RichText::Rendering::EmbeddedFormRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/formalist/rich_text/rendering/embedded_form_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container = {}, namespace: nil, paths: [], **options) ⇒ EmbeddedFormRenderer

Returns a new instance of EmbeddedFormRenderer.



10
11
12
13
14
15
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 10

def initialize(container = {}, namespace: nil, paths: [], **options)
  @container = container
  @namespace = namespace
  @paths = paths
  @options = options
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



5
6
7
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 5

def container
  @container
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 6

def namespace
  @namespace
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 8

def options
  @options
end

#pathsObject (readonly)

Returns the value of attribute paths.



7
8
9
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 7

def paths
  @paths
end

Instance Method Details

#call(form_data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 17

def call(form_data)
  type, data = form_data.values_at(:name, :data)

  key = resolve_key(type)

  if key
    container[key].(data, **options)
  else
    ""
  end
end

#with(**context_options) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/formalist/rich_text/rendering/embedded_form_renderer.rb', line 29

def with(**context_options)
  self.class.new(
    container,
    namespace: namespace,
    paths: paths,
    **options.merge(context_options)
  )
end