Sha256: ab62896d5b8207f67b203923b2a84ccfec1ad266b04a8c08000f28554adf1bbf

Contents?: true

Size: 547 Bytes

Versions: 1

Compression:

Stored size: 547 Bytes

Contents

require 'tori'

module Tori
  module ActiveRecord
    include Define

    # Filename hash usgin `id` attribute by default.
    # And you can change this attribute, But it's should be record unique.
    #
    # @example:
    # class Photo < ActiveRecord::Base
    #   tori :image
    # end
    def tori(name)
      super

      after_save do
        file = __send__ name
        file.copy
      end

      after_destroy do
        file = __send__ name
        file.delete
      end
    end
  end
end
::ActiveRecord::Base.extend(Tori::ActiveRecord)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tori-0.0.4 lib/tori/rails.rb