Sha256: 199f8ff0fde168e15711e3ae7729a96869b9b752974f0287b8c191271b18d2b0

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

module Yapper::Document
  module Attachment
    extend MotionSupport::Concern

    included do
      field(:_attachments)
    end

    def attach(name, attachments)
      raise "Attachment #{name} not defined on #{self.class}" unless Yapper::Attachment.attachments[name]

      self._attachments ||= {}
      self._attachments[name.to_s] = attachments.collect(&:id)
    end

    module ClassMethods
      def attach(name, options={}, &block)

        options[:block] = block

        field(name)
        Yapper::Attachment.attachments[name] = options
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-yapper-0.0.1 lib/yapper/document/attachment.rb