Class: Trenni::Formatters::HTML::AcceptCheckbox

Inherits:
Object
  • Object
show all
Defined in:
lib/trenni/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.



35
36
37
38
39
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 35

def initialize(formatter, builder, **options)
	@formatter = formatter
	@builder = builder
	@options = 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, **options, &block)
	instance = self.new(formatter, builder, **options)
	
	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(**options)
	@formatter.checkbox_attributes_for(**options)
end

#name_for(**options) ⇒ Object



41
42
43
# File 'lib/trenni/formatters/html/accept_checkbox.rb', line 41

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