Class: MrMime::Impersonation

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
app/models/mr_mime/impersonation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Impersonation

Returns a new instance of Impersonation.



17
18
19
20
21
22
# File 'app/models/mr_mime/impersonation.rb', line 17

def initialize(options = {})
  @adapter   = adapter_class.new(options.fetch(:context))
  @store     = MrMime::Store.new(options[:store] || {})
  @params    = options[:params] || {}
  @return_to = store.get(:return_to)
end

Instance Attribute Details

#return_toObject (readonly)

Returns the value of attribute return_to.



15
16
17
# File 'app/models/mr_mime/impersonation.rb', line 15

def return_to
  @return_to
end

Instance Method Details

#error_messagesObject



43
44
45
# File 'app/models/mr_mime/impersonation.rb', line 43

def error_messages
  errors.full_messages.join(', ')
end

#impersonatedObject



39
40
41
# File 'app/models/mr_mime/impersonation.rb', line 39

def impersonated
  @impersonated ||= find_user(params[:impersonated_id])
end

#impersonatorObject



35
36
37
# File 'app/models/mr_mime/impersonation.rb', line 35

def impersonator
  @impersonator ||= find_user(params[:impersonator_id])
end

#revertObject



31
32
33
# File 'app/models/mr_mime/impersonation.rb', line 31

def revert
  revert_user_keys
end

#saveObject



24
25
26
27
28
29
# File 'app/models/mr_mime/impersonation.rb', line 24

def save
  if valid?
    set_user_keys
    true
  end
end