Class: Caboose::MediaImage

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/caboose/media_image.rb

Instance Method Summary collapse

Instance Method Details

#api_hashObject



31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/caboose/media_image.rb', line 31

def api_hash
  {
    :id => self.id,
    :name => self.name,
    :description => self.description,
    :tiny_url => self.image.url(:tiny),
    :thumb_url => self.image.url(:thumb),
    :large_url => self.image.url(:large),
    :original_url => self.image.url(:original)
  }
end

#processObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/caboose/media_image.rb', line 19

def process
  
  config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
  bucket = config['bucket']
  
  uri = "http://#{bucket}.s3.amazonaws.com/media-images/#{self.id}#{File.extname(self.name.downcase)}"
  puts "Processing #{uri}..."
  
  self.image = URI.parse(uri)
  self.save
end