module AwesomePrint::CarrierWave

Public Class Methods

included(base) click to toggle source
# File lib/awesome_print/carrierwave.rb, line 3
def self.included(base)
  base.send :alias_method, :cast_without_carrierwave, :cast
  base.send :alias_method, :cast, :cast_with_carrierwave
end

Public Instance Methods

cast_with_carrierwave(object, type) click to toggle source

Add CarrierWave class names to the dispatcher pipeline.

# File lib/awesome_print/carrierwave.rb, line 9
def cast_with_carrierwave(object, type)
  if defined?(::CarrierWave) && object.is_a?(::CarrierWave::Uploader::Base)
    :carrierwave_uploader_instance
  else
    cast_without_carrierwave(object, type)
  end
end

Private Instance Methods

awesome_carrierwave_uploader_instance(uploader) click to toggle source

Format CarrierWave::Uploader instance object.

NOTE: by default only uploader class name, storage and serialiazed versions are shown. To format CarrierWave::Instance instance as regular object showing its instance variables and accessors use raw: true option:

ap record.uploader, raw: true
# File lib/awesome_print/carrierwave.rb, line 27
def awesome_carrierwave_uploader_instance(uploader)
  if @options[:raw]
    awesome_object(uploader)
  else
    "#{uploader.class.name} with #{uploader.class.storage_engines.key(uploader._storage.name)} " \
      << awesome_hash(uploader.serializable_hash)
  end
end