Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Spone committed Jun 26, 2021
1 parent e6eaa9d commit c7afc65
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions app/components/view_component/form/check_box_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,15 @@ def initialize(form, object_name, method_name, checked_value, unchecked_value, o
super(form, object_name, method_name, options)
end

def call # rubocop:disable Metrics/AbcSize Metrics/MethodLength
if options[:label] == false
ActionView::Helpers::Tags::CheckBox.new(
object_name,
method_name,
form,
checked_value,
unchecked_value,
options
).render
else
render(ViewComponent::Form::LabelComponent.new(form, object_name, method_name)) do
concat ActionView::Helpers::Tags::CheckBox.new(
object_name,
method_name,
form,
checked_value,
unchecked_value,
options
).render
concat tag.span(check_box_text)
end
end
end

def check_box_text
@check_box_text ||= ActionView::Helpers::Tags::Translator.new(
object, object_name, method_name, scope: "helpers.checkbox"
).translate
def call
ActionView::Helpers::Tags::CheckBox.new(
object_name,
method_name,
form,
checked_value,
unchecked_value,
options
).render
end
end
end
Expand Down

0 comments on commit c7afc65

Please sign in to comment.