Class: Yattho::Forms::Caption

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

Overview

:nodoc:

Instance Attribute Summary

Attributes included from ActsAsComponent

#template_root_path

Instance Method Summary collapse

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

#class_names

Constructor Details

#initialize(input:) ⇒ Caption

Returns a new instance of Caption.



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

def initialize(input:)
  @input = input
end

Instance Method Details

#before_renderObject



19
20
21
22
23
24
25
26
# File 'lib/yattho/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)


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

def caption_template?
  @input.caption_template?
end

#render_caption_templateObject



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

def render_caption_template
  @input.render_caption_template
end