Class: Caboose::ProductImage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Caboose::ProductImage
- Defined in:
- app/models/caboose/product_image.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #process ⇒ Object
-
#url(size) ⇒ Object
‘tiny’, ‘thumb’, ‘medium’, ‘large’, ‘huge’.
- #urls ⇒ Object
Instance Method Details
#as_json(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/caboose/product_image.rb', line 60 def as_json(={}) self.attributes.merge({ :urls => { :tiny => self.url(:tiny), :thumb => self.url(:thumb), :medium => self.url(:medium), :large => self.url(:large), :huge => self.url(:huge) } }) end |
#process ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/models/caboose/product_image.rb', line 38 def process config = AssetSync.config bucket = config.fog_directory uri = "http://#{bucket}.s3.amazonaws.com/media-images/#{self.id}#{File.extname(self.title.downcase)}" self.image = URI.parse(uri) self.save end |
#url(size) ⇒ Object
‘tiny’, ‘thumb’, ‘medium’, ‘large’, ‘huge’
46 47 48 |
# File 'app/models/caboose/product_image.rb', line 46 def url(size) # 'tiny', 'thumb', 'medium', 'large', 'huge' self.image.url(size) end |
#urls ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/models/caboose/product_image.rb', line 50 def urls { :tiny => self.url(:tiny), :thumb => self.url(:thumb), :medium => self.url(:medium), :large => self.url(:large), :huge => self.url(:huge) } end |