File: mountable.rb

package info (click to toggle)
ruby-carrierwave 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,692 kB
  • sloc: ruby: 9,881; sh: 26; makefile: 5
file content (38 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module CarrierWave
  module Uploader
    module Mountable

      attr_reader :model, :mounted_as

      ##
      # If a model is given as the first parameter, it will be stored in the
      # uploader, and available through +#model+. Likewise, mounted_as stores
      # the name of the column where this instance of the uploader is mounted.
      # These values can then be used inside your uploader.
      #
      # If you do not wish to mount your uploaders with the ORM extensions in
      # -more then you can override this method inside your uploader. Just be
      # sure to call +super+
      #
      # === Parameters
      #
      # [model (Object)] Any kind of model object
      # [mounted_as (Symbol)] The name of the column where this uploader is mounted
      #
      # === Examples
      #
      #     class MyUploader < CarrierWave::Uploader::Base
      #
      #       def store_dir
      #         File.join('public', 'files', mounted_as, model.permalink)
      #       end
      #     end
      #
      def initialize(model=nil, mounted_as=nil)
        @model = model
        @mounted_as = mounted_as
      end

    end # Mountable
  end # Uploader
end # CarrierWave