Sha256: 532fe247da3085df2b153fa69b485501aac3f940e2cc62e0920f67d8a0c701af

Contents?: true

Size: 519 Bytes

Versions: 2

Compression:

Stored size: 519 Bytes

Contents

module ::Mongoid
  module Document

    %w[logo avatar attach embed].each do |name|
    module_eval(%Q(
    def remove_#{name}
      attach=self.#{name}
      unless attach.blank?
        id = BSON::ObjectId.from_string(attach['grid_id'])
        MongoGrid.grid.delete(id)
      end
    end
    ))
    end

=begin
    def self.included(base)
      base.class_eval(%Q(
          before_destroy :remove_logo
          before_destroy :remove_avatar
          before_destroy :remove_attach
      ))
    end
=end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo_grid-0.2.8 lib/mongo_grid/mongoid.rb
mongo_grid-0.2.7 lib/mongo_grid/mongoid.rb