Module: CarrierWave::Uploader::Serialization

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/carrierwave/uploader/serialization.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object


13
14
15
# File 'lib/carrierwave/uploader/serialization.rb', line 13

def as_json(options=nil)
  serializable_hash
end

#serializable_hash(options = nil) ⇒ Object


9
10
11
# File 'lib/carrierwave/uploader/serialization.rb', line 9

def serializable_hash(options = nil)
  {"url" => url}.merge Hash[versions.map { |name, version| [name.to_s, { "url" => version.url }] }]
end

#to_json(options = nil) ⇒ Object


17
18
19
# File 'lib/carrierwave/uploader/serialization.rb', line 17

def to_json(options=nil)
  JSON.generate(as_json)
end

#to_xml(options = {}) ⇒ Object


21
22
23
24
# File 'lib/carrierwave/uploader/serialization.rb', line 21

def to_xml(options={})
  merged_options = options.merge(:root => mounted_as || "uploader", :type => 'uploader')
  serializable_hash.to_xml(merged_options)
end