Class: Digineo::Image

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/digineo/image.rb

Overview

require ‘RMagick’

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_urlObject

Returns the value of attribute file_url.



11
12
13
# File 'lib/digineo/image.rb', line 11

def file_url
  @file_url
end

Returns the value of attribute gallery_name.



12
13
14
# File 'lib/digineo/image.rb', line 12

def gallery_name
  @gallery_name
end

#image_type_nameObject

Returns the value of attribute image_type_name.



13
14
15
# File 'lib/digineo/image.rb', line 13

def image_type_name
  @image_type_name
end

Instance Method Details

#set_avatarObject

sets the avatar flag on this image



44
45
46
47
# File 'lib/digineo/image.rb', line 44

def set_avatar
  parentmodel.avatar.unset_avatar if parentmodel.avatar
  update_attribute(:avatar, true)
end


54
55
56
57
58
# File 'lib/digineo/image.rb', line 54

def set_gallery    
  return if gallery_id or gallery_name.to_s.empty?
  self.gallery_id = parentmodel.find_or_create_gallery(gallery_name).id
  save
end

#set_image_typeObject



60
61
62
63
64
# File 'lib/digineo/image.rb', line 60

def set_image_type    
  return if image_type_id or image_type_name.to_s.empty?
  self.image_type_id = ImageType.find_or_create_by_name(image_type_name).id
  save
end

#unset_avatarObject

removes avatar flag



50
51
52
# File 'lib/digineo/image.rb', line 50

def unset_avatar
  update_attribute(:avatar, false)
end