Class: Object

Inherits:
BasicObject
Defined in:
lib/fqdn_facts/core_ext.rb

Overview

See Also:

Instance Method Summary collapse

Instance Method Details

#empty?false

provides an empty? check for all objects unless an object already has an empty? check



25
26
27
# File 'lib/fqdn_facts/core_ext.rb', line 25

def empty?
  return false
end

#present?Boolean

returns true if the object “contains” data (object dependant)



32
33
34
# File 'lib/fqdn_facts/core_ext.rb', line 32

def present?
  !empty?
end

#try(method, *args, &block) ⇒ Object

attempts to call a public method



43
44
45
46
47
48
49
# File 'lib/fqdn_facts/core_ext.rb', line 43

def try(method, *args, &block)
  begin
    self.public_send(method, *args, &block)
  rescue NoMethodError
    nil
  end
end