mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:22:40 +08:00
DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827)
We have a custom implementation of #blank? in our Onebox helpers. This is likely a legacy from when Onebox was a standalone gem. This change replaces all usages with respective incarnations of #blank?, #present?, and #presence from ActiveSupport. It changes a bunch of "unless blank" to "if present" as well.
This commit is contained in:
@ -14,14 +14,13 @@ module Onebox
|
||||
def method_missing(attr, *args, &block)
|
||||
value = get(attr, *args)
|
||||
|
||||
return nil if Onebox::Helpers.blank?(value)
|
||||
return nil if value.blank?
|
||||
|
||||
method_name = attr.to_s
|
||||
if method_name.end_with?(*integer_suffixes)
|
||||
value.to_i
|
||||
elsif method_name.end_with?(*url_suffixes)
|
||||
result = Onebox::Helpers.normalize_url_for_output(value)
|
||||
result unless Onebox::Helpers.blank?(result)
|
||||
Onebox::Helpers.normalize_url_for_output(value).presence
|
||||
else
|
||||
value
|
||||
end
|
||||
|
Reference in New Issue
Block a user