Class: DeepHashTransformer::Blank

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_hash_transformer/blank.rb

Constant Summary collapse

BLANK_STRING =
/\A[[:space:]]*\z/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Blank

Returns a new instance of Blank.

[View source]

11
12
13
# File 'lib/deep_hash_transformer/blank.rb', line 11

def initialize(value)
  @value = value
end

Class Method Details

.call(value) ⇒ Object

[View source]

7
8
9
# File 'lib/deep_hash_transformer/blank.rb', line 7

def self.call(value)
  new(value).blank?
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)
[View source]

15
16
17
18
19
20
21
22
# File 'lib/deep_hash_transformer/blank.rb', line 15

def blank?
  return true unless value
  return value.blank? if value.respond_to?(:blank?)
  return BLANK_STRING.match?(value) if value.is_a?(String)
  return value.empty? if value.respond_to?(:empty?)

  false
end