Class: Primer::Forms::Caption

Inherits:
BaseComponent show all
Defined in:
app/lib/primer/forms/caption.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from BaseComponent

#content, inherited, #input?, #perform_render, #render?, #to_component, #type

Methods included from ActsAsComponent

#base_template_path, #compile!, extended, #renders_templates, #template_root_path

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(input:) ⇒ Caption

Returns a new instance of Caption.

[View source]

7
8
9
# File 'app/lib/primer/forms/caption.rb', line 7

def initialize(input:)
  @input = input
end

Instance Method Details

#before_renderObject

[View source]

19
20
21
22
23
24
25
26
# File 'app/lib/primer/forms/caption.rb', line 19

def before_render
  return unless @input.caption? && caption_template?

  raise <<~MESSAGE
    Please provide either a caption: argument or caption template for the
    '#{@input.name}' input; both were found.
  MESSAGE
end

#caption_template?Boolean

Returns:

  • (Boolean)
[View source]

11
12
13
# File 'app/lib/primer/forms/caption.rb', line 11

def caption_template?
  @input.caption_template?
end

#render_caption_templateObject

[View source]

15
16
17
# File 'app/lib/primer/forms/caption.rb', line 15

def render_caption_template
  @input.render_caption_template
end