Module: Kind::Presence

Extended by:
Presence
Included in:
Presence
Defined in:
lib/kind/presence.rb

Instance Method Summary collapse

Instance Method Details

#call(object) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kind/presence.rb', line 9

def call(object)
  return if KIND.nil_or_undefined?(object)

  return object.blank? ? nil : object if object.respond_to?(:blank?)

  return blank_str?(object) ? nil : object if String === object

  return object.empty? ? nil : object if object.respond_to?(:empty?)

  return object if object
end

#to_procObject



21
22
23
# File 'lib/kind/presence.rb', line 21

def to_proc
  -> object { call(object) }
end