Module: Mongoid::Utils Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Utility functions for Mongoid.
Constant Summary collapse
- PLACEHOLDER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
A unique placeholder value that will never accidentally collide with valid values. This is useful as a default keyword argument value when you want the argument to be optional, but you also want to be able to recognize that the caller did not provide a value for it.
Object.new.freeze
Instance Method Summary collapse
-
#monotonic_time ⇒ Float
private
This function should be used if you need to measure time.
-
#placeholder?(value) ⇒ true | false
private
Asks if the given value is a placeholder or not.
-
#truthy_string?(string) ⇒ true | false
private
Returns true if the string is any of the following values: “1”, “yes”, “true”, “on”.
Instance Method Details
#monotonic_time ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This function should be used if you need to measure time.
37 38 39 |
# File 'lib/mongoid/utils.rb', line 37 def monotonic_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
#placeholder?(value) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Asks if the given value is a placeholder or not.
21 22 23 |
# File 'lib/mongoid/utils.rb', line 21 def placeholder?(value) value == PLACEHOLDER end |
#truthy_string?(string) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if the string is any of the following values: “1”, “yes”, “true”, “on”. Anything else is assumed to be false. Case is ignored, as are leading or trailing spaces.
48 49 50 |
# File 'lib/mongoid/utils.rb', line 48 def truthy_string?(string) %w[ 1 yes true on ].include?(string.strip.downcase) end |