Module: DataMapper::Sanitizer::ClassMethods

Defined in:
lib/dm-sanitizer.rb

Instance Method Summary collapse

Instance Method Details

#disable_sanitizationObject



48
49
50
# File 'lib/dm-sanitizer.rb', line 48

def disable_sanitization
  self.sanitization_options[:disabled] = true
end

#sanitize(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dm-sanitizer.rb', line 27

def sanitize(options={})
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def self.sanitization_options=(options)
      @sanitization_options = options
    end
    
    def self.sanitization_options
      @sanitization_options
    end
    
    def sanitization_options
      self.class.sanitization_options
    end
  RUBY
  
  before :save, :sanitize! unless self.sanitization_options
  self.sanitization_options = DataMapper::Sanitizer.default_options.merge(options)
  remap_sanitization_modes!
  check_sanitization_modes
end