Module: WithDeletedUser

Included in:
User
Defined in:
app/models/concerns/with_deleted_user.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



2
3
4
5
6
# File 'app/models/concerns/with_deleted_user.rb', line 2

def self.prepended(base)
  super
  base.before_destroy :forbid_destroy!, if: :deleted_user?
  base.extend ClassMethods
end

Instance Method Details

#abbreviated_nameObject



12
13
14
15
16
# File 'app/models/concerns/with_deleted_user.rb', line 12

def abbreviated_name
  return super unless deleted_user?

  I18n.t(:deleted_user, locale: (Organization.current.locale rescue 'en'))
end

#deleted_user?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/models/concerns/with_deleted_user.rb', line 8

def deleted_user?
  self == User.deleted_user
end