Sha256: e9b701c221a5e1a29abf681b55184855dd9bc3323c15ec32ccc342612015143d

Contents?: true

Size: 690 Bytes

Versions: 56

Compression:

Stored size: 690 Bytes

Contents

module Brief
  class Document
    module Attachments
      def has_attachments?
        attachments.length > 0
      end

      def attachments
        Array(data.attachments)
      end

      def attachment_paths
        attachments.reduce({}.to_mash) do |memo, name|
          if asset = briefcase.find_asset(name)
            memo[name] = asset.realpath.to_s
            memo
          end
        end
      end

      def render_attachments
        attachments.reduce({}.to_mash) do |memo, name|
          if asset = briefcase.find_asset(name)
            memo[name] = IO.read(asset) if asset.to_s.match(/\.svg/i)
            memo
          end
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
brief-1.17.14 lib/brief/document/attachments.rb
brief-1.17.13 lib/brief/document/attachments.rb
brief-1.17.12 lib/brief/document/attachments.rb
brief-1.17.11 lib/brief/document/attachments.rb
brief-1.17.10 lib/brief/document/attachments.rb
brief-1.17.9 lib/brief/document/attachments.rb
brief-1.17.8 lib/brief/document/attachments.rb
brief-1.17.7 lib/brief/document/attachments.rb
brief-1.17.5 lib/brief/document/attachments.rb
brief-1.17.4 lib/brief/document/attachments.rb
brief-1.17.3 lib/brief/document/attachments.rb
brief-1.17.2 lib/brief/document/attachments.rb
brief-1.17.1 lib/brief/document/attachments.rb
brief-1.17.0 lib/brief/document/attachments.rb
brief-1.16.2 lib/brief/document/attachments.rb
brief-1.16.1 lib/brief/document/attachments.rb
brief-1.16.0 lib/brief/document/attachments.rb
brief-1.15.5 lib/brief/document/attachments.rb
brief-1.15.4 lib/brief/document/attachments.rb
brief-1.15.3 lib/brief/document/attachments.rb