Sha256: f049462bf6b27c41bbaa56d13b77298bc69e19b4c1c2b1794cf58d1ddf34180f

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

require 'set'
require 'mime/types'
require 'wand'

module Joint
  def self.configure(model)
    model.class_inheritable_accessor :attachment_names
    model.attachment_names = Set.new
    model.send(:include, model.attachment_accessor_module)
  end

  def self.name(file)
    if file.respond_to?(:original_filename)
      file.original_filename
    else
      File.basename(file.path)
    end
  end

  def self.size(file)
    if file.respond_to?(:size)
      file.size
    else
      File.size(file)
    end
  end

  def self.type(file)
    if file.respond_to?(:content_type)
      file.content_type
    else
      Wand.wave(file.path, :original_filename => Joint.name(file))
    end
  end
end

require 'joint/class_methods'
require 'joint/instance_methods'
require 'joint/attachment_proxy'
require 'joint/io'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joint-0.5.3 lib/joint.rb
joint-0.5.2 lib/joint.rb