Sha256: 366f81e55d6586a1a2a1ffb5c2896d24399790cfa22da8f45150704d6c36506d

Contents?: true

Size: 627 Bytes

Versions: 11

Compression:

Stored size: 627 Bytes

Contents

module Dragonfly
  module ActiveRecordExtensions
    module InstanceMethods
      
      def attachments
        @attachments ||= self.class.dragonfly_apps_for_attributes.inject({}) do |hash, (attribute, app)|
          hash[attribute] = Attachment.new(app, self, attribute)
          hash
        end
      end

      private
      
      def save_attachments
        attachments.each do |attribute, attachment|
          attachment.save!
        end
      end
      
      def destroy_attachments
        attachments.each do |attribute, attachment|
          attachment.destroy!
        end
      end
      
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dragonfly-0.6.2 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.6.1 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.6.0 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.7 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.6 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.5 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.4 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.3 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.2 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.1 lib/dragonfly/active_record_extensions/instance_methods.rb
dragonfly-0.5.0 lib/dragonfly/active_record_extensions/instance_methods.rb