Class: Primer::Forms::Caption
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Primer::Forms::Caption
- Defined in:
- lib/primer/forms/caption.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes included from ActsAsComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #caption_template? ⇒ Boolean
-
#initialize(input:) ⇒ Caption
constructor
A new instance of Caption.
- #render_caption_template ⇒ Object
Methods inherited from BaseComponent
#content, inherited, #input?, #perform_render, #render?, #to_component, #type
Methods included from ActsAsComponent
#compile!, extended, #renders_templates
Methods included from ClassNameHelper
Constructor Details
#initialize(input:) ⇒ Caption
Returns a new instance of Caption.
7 8 9 |
# File 'lib/primer/forms/caption.rb', line 7 def initialize(input:) @input = input end |
Instance Method Details
#before_render ⇒ Object
19 20 21 22 23 24 25 26 |
# File '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
11 12 13 |
# File 'lib/primer/forms/caption.rb', line 11 def caption_template? @input.caption_template? end |
#render_caption_template ⇒ Object
15 16 17 |
# File 'lib/primer/forms/caption.rb', line 15 def render_caption_template @input.render_caption_template end |