Skip to content

Commit 4b4d145

Browse files
committed
Eliminate some Integer() rescue nil patterns in Action Text
1 parent a3cfa4a commit 4b4d145

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

actiontext/lib/action_text/trix_attachment.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class TrixAttachment
99
ATTRIBUTES = %w( sgid contentType url href filename filesize width height previewable content ) + COMPOSED_ATTRIBUTES
1010
ATTRIBUTE_TYPES = {
1111
"previewable" => ->(value) { value.to_s == "true" },
12-
"filesize" => ->(value) { Integer(value.to_s) rescue value },
13-
"width" => ->(value) { Integer(value.to_s) rescue nil },
14-
"height" => ->(value) { Integer(value.to_s) rescue nil },
12+
"filesize" => ->(value) { Integer(value.to_s, exception: false) || value },
13+
"width" => ->(value) { Integer(value.to_s, exception: false) },
14+
"height" => ->(value) { Integer(value.to_s, exception: false) },
1515
:default => ->(value) { value.to_s }
1616
}
1717

0 commit comments

Comments
 (0)