Module: BSON::Environment

Extended by:
Environment
Included in:
Environment
Defined in:
lib/bson/environment.rb

Overview

Provides static helper methods around determining what environment is running without polluting the global namespace.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#jruby?true, false

Determine if we are using JRuby or not.

Examples:

Are we running with JRuby?

Environment.jruby?

Returns:

  • (true, false)

    If JRuby is our vm.

Since:

  • 2.0.0



32
33
34
# File 'lib/bson/environment.rb', line 32

def jruby?
  defined?(JRUBY_VERSION)
end

#ree?true, false

Determine if we are using REE or not.

Examples:

Are we running with REE?

Environment.ree?

Returns:

  • (true, false)

    If our vm is REE.

Since:

  • 2.1.0



44
45
46
# File 'lib/bson/environment.rb', line 44

def ree?
  RUBY_ENGINE == "ruby" && RUBY_DESCRIPTION =~ /Enterprise/
end

#retaining_hash_order?true, false

Does the Ruby runtime we are using support ordered hashes?

Examples:

Does the runtime support ordered hashes?

Environment.retaining_hash_order?

Returns:

  • (true, false)

    If the runtime has ordered hashes.

Since:

  • 2.0.0



56
57
58
# File 'lib/bson/environment.rb', line 56

def retaining_hash_order?
  jruby? || RUBY_VERSION > "1.9.1"
end

#ruby_18?true, false

Are we running in a ruby runtime that is version 1.8.x?

Examples:

Is the ruby runtime in 1.8 mode?

Environment.ruby_18?

Returns:

  • (true, false)

    If we are running in 1.8.

Since:

  • 2.0.0



68
69
70
# File 'lib/bson/environment.rb', line 68

def ruby_18?
  RUBY_VERSION < "1.9"
end