class Formalist::RichText::Rendering::EmbeddedFormRenderer
Attributes
container[R]
namespace[R]
options[R]
paths[R]
Public Class Methods
new(container = {}, namespace: nil, paths: [], **options)
click to toggle source
# 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
Public Instance Methods
call(form_data)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
resolve_key(type)
click to toggle source
# File lib/formalist/rich_text/rendering/embedded_form_renderer.rb, line 40 def resolve_key(type) paths.each do |path| path_key = path.tr("/", ".") key = [namespace, path_key, type].compact.join(".") return key if container.key?(key) end key = [namespace, type].compact.join(".") return key if container.key?(key) end