Module: UU::OS::Lang::ConstantHelper

Defined in:
uu_os_commons-1.5.0/lib/uu/os/lang/constant_helper.rb

Overview

Module providing methods const_defined? and const_get allowing

to use name of constant with

even on Ruby < 2.0.

Instance Method Summary (collapse)

Instance Method Details

- (TrueClass, FalseClass) constant_defined?(constant, root = Object)

Checks if constant is defined.

Parameters:

  • constant (String)

    Constant name (may include ::).

  • root (Class) (defaults to: Object)

    Root from which to search for constant (default to Object).

Returns:

  • (TrueClass, FalseClass)

    True if constant is defined.



13
14
15
# File 'uu_os_commons-1.5.0/lib/uu/os/lang/constant_helper.rb', line 13

def constant_defined?(constant, root = Object)
  return ConstantHelper.constant_defined?(constant, root)
end

- (Object) constant_get(constant, root = Object)

Returns constant value.

Parameters:

  • constant (String)

    Constant name (may include ::).

  • root (Class) (defaults to: Object)

    Root from which to search for constants (default to Object).

Returns:

  • (Object)

    Constant value.

Raises:

  • (NameError)

    If constant is not defined.



22
23
24
# File 'uu_os_commons-1.5.0/lib/uu/os/lang/constant_helper.rb', line 22

def constant_get(constant, root = Object)
  return ConstantHelper.constant_get(constant, root)
end