Sha256: cd25d6ae9cee3189eff64f019a18a214c96f18f0c2983e3fb4989b2e6d6e9fc4

Contents?: true

Size: 984 Bytes

Versions: 7

Compression:

Stored size: 984 Bytes

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, :inverse_of => :image

    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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
attachment_magick-0.2.6 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.5 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.4 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.3 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.2 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.1 app/models/attachment_magick/mongoid_image.rb
attachment_magick-0.2.0 app/models/attachment_magick/mongoid_image.rb