Class: Decidim::Comments::CommentForm

Inherits:
Form
  • Object
show all
Defined in:
decidim-comments/app/forms/decidim/comments/comment_form.rb

Overview

A form object used to create comments from the graphql api.

Instance Method Summary collapse

Instance Method Details

#max_depthObject


31
32
33
34
35
# File 'decidim-comments/app/forms/decidim/comments/comment_form.rb', line 31

def max_depth
  return unless commentable.respond_to?(:depth)

  errors.add(:base, :invalid) if commentable.depth >= Comment::MAX_DEPTH
end

#max_lengthObject


21
22
23
24
25
26
27
28
29
# File 'decidim-comments/app/forms/decidim/comments/comment_form.rb', line 21

def max_length
  if current_component.try(:settings).respond_to?(:comments_max_length)
    component_length = current_component.try { settings.comments_max_length.positive? }
    return current_component.settings.comments_max_length if component_length
  end
  return current_organization.comments_max_length if current_organization.comments_max_length.positive?

  1000
end