module MailerLite::Utils
Constants
- BLANK_RE
Public Class Methods
blank?(obj)
click to toggle source
# File lib/mailerlite/utils.rb, line 16 def blank?(obj) return !!BLANK_RE.match(obj) if obj.is_a?(String) obj.respond_to?(:empty?) ? !!obj.empty? : !obj end
presence(obj)
click to toggle source
# File lib/mailerlite/utils.rb, line 26 def presence(obj) obj if present?(obj) end
present?(obj)
click to toggle source
# File lib/mailerlite/utils.rb, line 22 def present?(obj) !blank?(obj) end
underscore(string)
click to toggle source
# File lib/mailerlite/utils.rb, line 8 def underscore(string) string.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end