Module: MongoMapper::Utils

Defined in:
lib/mongo_mapper/utils.rb

Class Method Summary collapse

Class Method Details

.filter_param(name, raw_value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mongo_mapper/utils.rb', line 12

def self.filter_param(name, raw_value)
  if ActiveSupport.version >= Gem::Version.new("6.0")
    @filter ||= begin
      require "active_support/parameter_filter"
      ActiveSupport::ParameterFilter.new(MongoMapper.filter_attributes)
    end
    @filter.filter_param(name, raw_value)
  else
    raw_value
  end
end

.get_safe_options(options) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/mongo_mapper/utils.rb', line 3

def self.get_safe_options(options)
  return {} unless options and options.key? :safe
  safe = options[:safe]
  safe = {:w => 1} if safe == true
  safe = {:w => 0} if safe == false
  safe = {:w => safe} if safe.is_a? Integer
  safe
end