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.



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

def file_url
  @file_url
end

Returns the value of attribute gallery_name.



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

def gallery_name
  @gallery_name
end

#image_type_nameObject

Returns the value of attribute image_type_name.



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

def image_type_name
  @image_type_name
end

Instance Method Details

#set_avatarObject

sets the avatar flag on this image



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

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


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

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



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

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



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

def unset_avatar
  update_attribute(:avatar, false)
end