Module: Devise::Orm::DataMapper::Compatibility

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/orm/data_mapper/compatibility.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#assign_attributes(params, *options) ⇒ Object



56
57
58
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 56

def assign_attributes(params, *options)
  self.attributes = params
end

#changed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 36

def changed?
  dirty?
end

#email_changed?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 64

def email_changed?
  attribute_dirty?(:email) && self.email.present?
end

#email_wasObject



72
73
74
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 72

def email_was
  original_attributes[:email]
end

#encrypted_password_changed?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 68

def encrypted_password_changed?
  attribute_dirty?(:email) && self.encrypted_password.present?
end

#invalid?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 60

def invalid?
  !valid?
end

#properties_to_serialize(options = nil) ⇒ Object

Redefine properties_to_serialize in models for more secure defaults. By default, it removes from the serializable model all attributes that are not accessible. You can remove this default by using :force_exclude and passing a new list of attributes you want to exempt. All attributes given to :exclude will simply add names to exempt to Devise internal list.



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 81

def properties_to_serialize(options=nil)
  options ||= {}
  if options.key?(:force_except) || options.key?(:force_exclude)
    options[:exclude] = options.delete(:force_except) || options.delete(:force_exclude)
    super(options)
  else
    blacklist = Devise::Models::Authenticatable.const_defined?(:BLACKLIST_FOR_SERIALIZATION) ? Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION : []
    except = Array(options[:exclude]) + Array(options[:except]) + blacklist
    super(options.merge(:exclude => except))
  end
end

#save(options = nil) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 40

def save(options=nil)
  if options.is_a?(Hash) && options[:validate] == false
    _persist
  else
    super()
  end
end

#update_attribute(name, value) ⇒ Object



48
49
50
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 48

def update_attribute(name, value)
  update(name => value)
end

#update_attributes(*args) ⇒ Object



52
53
54
# File 'lib/devise/orm/data_mapper/compatibility.rb', line 52

def update_attributes(*args)
  update(*args)
end