Class: Trenni::Formatters::HTML::AcceptCheckbox
- Inherits:
-
Object
- Object
- Trenni::Formatters::HTML::AcceptCheckbox
- Defined in:
- lib/trenni/formatters/html/accept_checkbox.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(&block) ⇒ Object
- #checkbox_attributes_for(**options) ⇒ Object
-
#initialize(formatter, builder, **options) ⇒ AcceptCheckbox
constructor
A new instance of AcceptCheckbox.
- #name_for(**options) ⇒ Object
Constructor Details
#initialize(formatter, builder, **options) ⇒ AcceptCheckbox
Returns a new instance of AcceptCheckbox.
35 36 37 38 39 |
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 35 def initialize(formatter, builder, **) @formatter = formatter @builder = builder @options = end |
Class Method Details
.call(formatter, builder, **options, &block) ⇒ Object
29 30 31 32 33 |
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 29 def self.call(formatter, builder, **, &block) instance = self.new(formatter, builder, **) instance.call(&block) end |
Instance Method Details
#call(&block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 49 def call(&block) Builder.fragment(@builder) do |builder| builder.inline('span') do builder.inline :input, type: :hidden, name: name_for(**@options), value: 'false' builder.tag :input, checkbox_attributes_for(**@options) builder.text " " builder.capture(self, &block) end end end |
#checkbox_attributes_for(**options) ⇒ Object
45 46 47 |
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 45 def checkbox_attributes_for(**) @formatter.checkbox_attributes_for(**) end |
#name_for(**options) ⇒ Object
41 42 43 |
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 41 def name_for(**) @formatter.name_for(**) end |