Sha256: cf90d4a700a93dc91eea2d747305ad94383dd9ae2142676b4d5a04578af5405a

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require "mime/types"

module AttachmentMagick
  class MongoidImage
    include Mongoid::Document
    # include AutoHtml
    include AutoHtmlFor

    before_create :set_content_type

    attr_accessor :file_name

    field           :photo_uid
    field           :caption
    field           :priority
    field           :source
    field           :content_type
    image_accessor  :photo
    
    embedded_in     :imageable, :polymorphic => true

    auto_html_for :source => "_to_html" do
      youtube(:width => 620, :height => 465)
      vimeo(:width => 620, :height => 465)
    end
    
    auto_html_for :source => "_to_image" do
      youtube_image
      vimeo_image(:size => :large)
    end

    def imageable
      self._parent
    end

    #FIXME - find a better way to compare
    def is_flash?
      self.content_type =~ /flash/ ? true : false
    end

    private
    def set_content_type
      self.content_type = MIME::Types.type_for(self.file_name.to_s).to_s
    end
  end if AttachmentMagick.configuration.orms.include?("Mongoid")
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attachment_magick-0.3.6 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.3.5 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.3.4 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.3.3 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.3.2 app/models/attachment_magick/mongoid_image.rb