Module: Mongo::Lint Private

Defined in:
lib/mongo/lint.rb

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.

Class Method Summary collapse

Class Method Details

.enabled?Boolean

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:

  • (Boolean)


40
41
42
# File 'lib/mongo/lint.rb', line 40

def enabled?
  ENV['MONGO_RUBY_DRIVER_LINT'] && %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_LINT'].downcase)
end

.validate_camel_case_read_preference(read_pref) ⇒ Object

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.



22
23
24
25
26
27
# File 'lib/mongo/lint.rb', line 22

def validate_camel_case_read_preference(read_pref)
  return unless enabled?
  if read_pref
    validate_camel_case_read_preference_mode(read_pref[:mode] || read_pref['mode'])
  end
end

.validate_camel_case_read_preference_mode(mode) ⇒ Object

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.



30
31
32
33
34
35
36
37
# File 'lib/mongo/lint.rb', line 30

def validate_camel_case_read_preference_mode(mode)
  return unless enabled?
  if mode
    unless %w(primary primaryPreferred secondary secondaryPreferred nearest).include?(mode.to_s)
      raise Error::LintError, "Invalid read preference mode: #{mode}"
    end
  end
end

.validate_underscore_read_preference(read_pref) ⇒ Object

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.



4
5
6
7
8
9
# File 'lib/mongo/lint.rb', line 4

def validate_underscore_read_preference(read_pref)
  return unless enabled?
  if read_pref
    validate_underscore_read_preference_mode(read_pref[:mode] || read_pref['mode'])
  end
end

.validate_underscore_read_preference_mode(mode) ⇒ Object

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.



12
13
14
15
16
17
18
19
# File 'lib/mongo/lint.rb', line 12

def validate_underscore_read_preference_mode(mode)
  return unless enabled?
  if mode
    unless %w(primary primary_preferred secondary secondary_preferred nearest).include?(mode.to_s)
      raise Error::LintError, "Invalid read preference mode: #{mode}"
    end
  end
end