Sha256: 8054f1eafb37bdcb814d3237ac8ecb8fbca107d8884f12980c81e60de05c8e2c

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

require "s3_multipart/uploader/callbacks"
require "s3_multipart/uploader/validations"
require 'active_support/core_ext/string'
require "digest/sha1"

module S3Multipart
  module Uploader

    class << self
      attr_accessor :controllers
    end

    self.controllers = {}

    def self.serialize(controller)
      controllers[controller.to_s.to_sym]
    end

    # What is wrong with this method?
    def self.deserialize(digest)
      controllers.key(digest).to_s.constantize
    end

    # Generated multipart upload controllers (which reside in the app/uploaders/multipart
    # directory in the Rails application) extend this module.
    module Core

      include S3Multipart::Uploader::Callbacks
      include S3Multipart::Uploader::Validations

      def self.extended(klass)
        Uploader.controllers[klass.to_s.to_sym] = Digest::SHA1.hexdigest(klass.to_s)
      end

      def attach(model)
        S3Multipart::Upload.class_eval do
          has_one(model)
        end
      end

    end

  end 
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
s3_multipart-0.0.8 lib/s3_multipart/uploader.rb
s3_multipart-0.0.7 lib/s3_multipart/uploader.rb
s3_multipart-0.0.6 lib/s3_multipart/uploader.rb