Sha256: 9bc32f52d2ff388adbca73f216c4826c9054533ef77546e75cb0bdf16c70c0c0

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

module AppleNews
  class Document
    module Attachments
      extend ActiveSupport::Concern

      included do
        def add_file(file, mime = nil)
          filename = Pathname.new(file).basename.to_s
          mime ||= MIME::Types.type_for(filename)

          @files[filename] = UploadIO.new(file, mime, filename)
        end

        def add_file_at_path(path)
          add_file(File.new(path))
        end

        def add_string_as_file(name, contents, type)
          @files[name] = UploadIO.new(StringIO.new(contents), type, name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apple-news-0.1.0 lib/apple-news/document/attachments.rb