Module: Mova

Defined in:
lib/mova.rb,
lib/mova/scope.rb,
lib/mova/translator.rb,
lib/mova/storage/chain.rb,
lib/mova/storage/memory.rb,
lib/mova/storage/readonly.rb,
lib/mova/read_strategy/lazy.rb,
lib/mova/read_strategy/eager.rb,
lib/mova/interpolation/sprintf.rb

Defined Under Namespace

Modules: Interpolation, ReadStrategy, Scope, Storage Classes: Translator

Constant Summary collapse

EMPTY_TRANSLATION =
"".freeze

Class Method Summary collapse

Class Method Details

.presence(translation) ⇒ String?

Note:

Unlike ActiveSupport's Object#presence this method doesn't treat a string made of spaces as blank

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

Examples:

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

Since:

  • 0.1.0


22
23
24
25
# File 'lib/mova.rb', line 22

def self.presence(translation)
  return nil if translation == EMPTY_TRANSLATION
  translation
end