Class: Devise::BaseSanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/parameter_sanitizer.rb

Direct Known Subclasses

ParameterSanitizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, resource_name, params) ⇒ BaseSanitizer

Returns a new instance of BaseSanitizer.



5
6
7
8
9
10
# File 'lib/devise/parameter_sanitizer.rb', line 5

def initialize(resource_class, resource_name, params)
  @resource_class = resource_class
  @resource_name  = resource_name
  @params         = params
  @blocks         = Hash.new
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/devise/parameter_sanitizer.rb', line 3

def params
  @params
end

#resource_classObject (readonly)

Returns the value of attribute resource_class.



3
4
5
# File 'lib/devise/parameter_sanitizer.rb', line 3

def resource_class
  @resource_class
end

#resource_nameObject (readonly)

Returns the value of attribute resource_name.



3
4
5
# File 'lib/devise/parameter_sanitizer.rb', line 3

def resource_name
  @resource_name
end

Instance Method Details

#for(kind, &block) ⇒ Object



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

def for(kind, &block)
  if block_given?
    @blocks[kind] = block
  else
    block = @blocks[kind]
    block ? block.call(default_params) : fallback_for(kind)
  end
end