Class: Photo
- Inherits:
-
Object
- Object
- Photo
- Includes:
- Ish::Utils, Mongoid::Document, Mongoid::Paperclip, Mongoid::Timestamps
- Defined in:
- lib/photo.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Ish::Utils
Instance Attribute Details
#content_type ⇒ Object
68 69 70 |
# File 'lib/photo.rb', line 68 def content_type @content_type end |
#image_data ⇒ Object
68 69 70 |
# File 'lib/photo.rb', line 68 def image_data @image_data end |
#original_filename ⇒ Object
68 69 70 |
# File 'lib/photo.rb', line 68 def original_filename @original_filename end |
Class Method Details
.n_per_manager_gallery ⇒ Object
54 55 56 |
# File 'lib/photo.rb', line 54 def self.n_per_manager_gallery 25 end |
Instance Method Details
#decode_base64_image ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/photo.rb', line 69 def decode_base64_image if image_data && content_type && original_filename decoded_data = Base64.decode64(image_data) data = StringIO.new(decoded_data) data.class_eval do attr_accessor :content_type, :original_filename end data.content_type = content_type data.original_filename = File.basename(original_filename) self.photo = data end end |
#export_fields ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/photo.rb', line 58 def export_fields %w| gallery_id name descr weight is_public is_trash photo_file_name photo_content_type photo_file_size photo_updated_at photo_fingerprint | end |
#name ⇒ Object
20 21 22 23 24 |
# File 'lib/photo.rb', line 20 def name return self[:name] if self[:name] update_attribute(:name, self.photo.to_s.split('/').last.split('?').first) name end |