Class: XRB::Formatters::HTML::AcceptCheckbox

Inherits:
Object
  • Object
show all
Defined in:
lib/xrb/formatters/html/accept_checkbox.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatter, builder, **options) ⇒ AcceptCheckbox

Returns a new instance of AcceptCheckbox.



18
19
20
21
22
# File 'lib/xrb/formatters/html/accept_checkbox.rb', line 18

def initialize(formatter, builder, **options)
	@formatter = formatter
	@builder = builder
	@options = options
end

Class Method Details

.call(formatter, builder, **options, &block) ⇒ Object



12
13
14
15
16
# File 'lib/xrb/formatters/html/accept_checkbox.rb', line 12

def self.call(formatter, builder, **options, &block)
	instance = self.new(formatter, builder, **options)
	
	instance.call(&block)
end

Instance Method Details

#call(&block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/xrb/formatters/html/accept_checkbox.rb', line 32

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



28
29
30
# File 'lib/xrb/formatters/html/accept_checkbox.rb', line 28

def checkbox_attributes_for(**options)
	@formatter.checkbox_attributes_for(**options)
end

#name_for(**options) ⇒ Object



24
25
26
# File 'lib/xrb/formatters/html/accept_checkbox.rb', line 24

def name_for(**options)
	@formatter.name_for(**options)
end