Skip to content

Commit b5fc427

Browse files
committed
Apply code review suggestions
1 parent 803d586 commit b5fc427

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

lib/ruby_ui/separator/separator.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ module RubyUI
44
class Separator < Base
55
ORIENTATIONS = %i[horizontal vertical].freeze
66

7-
def initialize(as: "div", orientation: :horizontal, decorative: true, **attrs)
7+
def initialize(as: :div, orientation: :horizontal, decorative: true, **attrs)
88
raise ArgumentError, "Invalid orientation: #{orientation}" unless ORIENTATIONS.include?(orientation.to_sym)
99

10-
@as = as
10+
@as = as.to_sym
1111
@orientation = orientation.to_sym
1212
@decorative = decorative
1313
super(**attrs)
1414
end
1515

1616
def view_template(&)
17-
public_send(@as, **attrs, &)
17+
tag(@as, **attrs, &)
1818
end
1919

2020
private
@@ -25,10 +25,7 @@ def default_attrs
2525
class: [
2626
"shrink-0 bg-border",
2727
orientation_classes
28-
],
29-
data: {
30-
orientation: @orientation
31-
}
28+
]
3229
}
3330
end
3431

test/ruby_ui/separator_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def test_render
1010

1111
assert_match(/div/, output)
1212
assert_match(/role="none"/, output)
13-
assert_match(/data-orientation="horizontal"/, output)
13+
assert_match(/h-\[1px\]/, output)
1414
end
1515

1616
def test_render_with_vertical_orientation
1717
output = phlex do
1818
RubyUI.Separator(orientation: :vertical)
1919
end
2020

21-
assert_match(/data-orientation="vertical"/, output)
21+
assert_match(/w-\[1px\]/, output)
2222
end
2323

2424
def test_render_with_decorative_false
@@ -34,6 +34,6 @@ def test_render_with_custom_tag
3434
RubyUI.Separator(as: "hr")
3535
end
3636

37-
assert_match(/hr/, output)
37+
assert_match(/<hr/, output)
3838
end
3939
end

0 commit comments

Comments
 (0)