mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Simplify serializable_hash implementation
Now that Rails 3.1 is not supported anymore, we don't need to implement to_xml, since it does the right thing by calling serializable_hash. This removes the class_eval need that existed to simplify the implementation of both to_xml and serializable_hash.
This commit is contained in:
parent
79c6f47ad3
commit
2f0002a449
2 changed files with 15 additions and 22 deletions
|
@ -516,7 +516,7 @@ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simpl
|
||||||
|
|
||||||
### Heroku
|
### Heroku
|
||||||
|
|
||||||
Using Devise on Heroku with Ruby on Rails 3.1 requires setting:
|
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
config.assets.initialize_on_precompile = false
|
config.assets.initialize_on_precompile = false
|
||||||
|
|
|
@ -96,29 +96,22 @@ module Devise
|
||||||
def authenticatable_salt
|
def authenticatable_salt
|
||||||
end
|
end
|
||||||
|
|
||||||
array = %w(serializable_hash)
|
# Redefine serializable_hash in models for more secure defaults.
|
||||||
# to_xml does not call serializable_hash on 3.1
|
# By default, it removes from the serializable model all attributes that
|
||||||
array << "to_xml" if ActiveModel::VERSION::STRING[0,3] == "3.1"
|
# are *not* accessible. You can remove this default by using :force_except
|
||||||
|
# and passing a new list of attributes you want to exempt. All attributes
|
||||||
|
# given to :except will simply add names to exempt to Devise internal list.
|
||||||
|
def serializable_hash(options = nil)
|
||||||
|
options ||= {}
|
||||||
|
options[:except] = Array(options[:except])
|
||||||
|
|
||||||
array.each do |method|
|
if options[:force_except]
|
||||||
class_eval <<-RUBY, __FILE__, __LINE__
|
options[:except].concat Array(options[:force_except])
|
||||||
# Redefine to_xml and serializable_hash in models for more secure defaults.
|
else
|
||||||
# By default, it removes from the serializable model all attributes that
|
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
||||||
# are *not* accessible. You can remove this default by using :force_except
|
end
|
||||||
# and passing a new list of attributes you want to exempt. All attributes
|
|
||||||
# given to :except will simply add names to exempt to Devise internal list.
|
|
||||||
def #{method}(options=nil)
|
|
||||||
options ||= {}
|
|
||||||
options[:except] = Array(options[:except])
|
|
||||||
|
|
||||||
if options[:force_except]
|
super(options)
|
||||||
options[:except].concat Array(options[:force_except])
|
|
||||||
else
|
|
||||||
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
|
||||||
end
|
|
||||||
super(options)
|
|
||||||
end
|
|
||||||
RUBY
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
Loading…
Add table
Reference in a new issue