Class: Avatar

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/generators/authkit/templates/app/models/avatar.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/generators/authkit/templates/app/models/avatar.rb', line 14

def as_json(options = {})
  super({
    methods: [:url]
  }.merge(options))
end

#import!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/authkit/templates/app/models/avatar.rb', line 24

def import!
  return false unless self.attachment_importing?
  self.attachment_importing = false
  if self.remote_url.present?
    uri = URI.parse(self.remote_url)
    self.attachment = uri
    self.attachment_file_name = File.basename(URI.decode(uri.path))
  end
  self.save
end

#urlObject



20
21
22
# File 'lib/generators/authkit/templates/app/models/avatar.rb', line 20

def url
  self.attachment.url(:thumb)
end