module Mova

Constants

EMPTY_TRANSLATION

Public Class Methods

presence(translation) click to toggle source

@return [String] if translation is non-empty string @return [nil] if translation is nil or an empty string

@example

Mova.presence("hello") #=> "hello"
Mova.presence(nil) #=> nil
Mova.presence("") #=> nil

@note Unlike ActiveSupport’s Object#presence this method doesn’t

treat a string made of spaces as blank
  "  ".presence #=> nil
  Mova.presence("  ") #=> "  "

@since 0.1.0

# File lib/mova.rb, line 22
def self.presence(translation)
  return nil if translation == EMPTY_TRANSLATION
  translation
end