Module: CarrierWave::NoBrainer

Includes:
Mount
Included in:
NoBrainer::Document::ClassMethods
Defined in:
lib/carrierwave-nobrainer.rb

Instance Method Summary collapse

Instance Method Details

#mount_uploader(column, uploader = nil, options = {}, &block) ⇒ Object

See CarrierWave::Mount#mount_uploader for documentation



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/carrierwave-nobrainer.rb', line 18

def mount_uploader(column, uploader = nil, options = {}, &block)
  if options[:filename]
    super(column, uploader, options) do
      define_method(:filename) { options[:filename] }
    end
  else
    super
  end

  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def remote_#{column}_url=(url)
      column = _mounter(:#{column}).serialization_column
      attribute_may_change("#{column}")
      super
    end
  RUBY
end

#mount_uploaders(column, uploader = nil, options = {}, &block) ⇒ Object

See CarrierWave::Mount#mount_uploaders for documentation



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/carrierwave-nobrainer.rb', line 39

def mount_uploaders(column, uploader = nil, options = {}, &block)
  super

  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def remote_#{column}_urls=(url)
      column = _mounter(:#{column}).serialization_column
      attribute_may_change("#{column}")
      super
    end
  RUBY
end