class Formalist::RichText::ValidityCheck
Constants
- AST
Public Instance Methods
call(ast)
click to toggle source
# File lib/formalist/rich_text/validity_check.rb, line 8 def call(ast) forms = ast.map { |node| visit(node) }.flatten form_validity_check = Form::ValidityCheck.new forms.all? { |form_ast| form_validity_check.(form_ast.ast) } end
Also aliased as: []
Private Instance Methods
visit(node)
click to toggle source
# File lib/formalist/rich_text/validity_check.rb, line 18 def visit(node) name, nodes = node handler = :"visit_#{name}" if respond_to?(handler, true) send(handler, nodes) else [] end end
visit_block(node)
click to toggle source
We need to visit blocks in order to get to the formalist entities nested within them
# File lib/formalist/rich_text/validity_check.rb, line 31 def visit_block(node) type, id, children = node children.map { |child| visit(child) } end
visit_entity(node)
click to toggle source
# File lib/formalist/rich_text/validity_check.rb, line 37 def visit_entity(node) type, key, mutability, entity_data, children = node if type == "formalist" [AST.new(entity_data["form"])] else [] end end