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

- (Object) as_json(options = nil)



15
16
17
# File 'lib/carrierwave/uploader/serialization.rb', line 15

def as_json(options=nil)
  Hash[mounted_as || "uploader", serializable_hash]
end

- (Object) serializable_hash(options = nil)



11
12
13
# File 'lib/carrierwave/uploader/serialization.rb', line 11

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

- (Object) to_json(options = nil)



19
20
21
# File 'lib/carrierwave/uploader/serialization.rb', line 19

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

- (Object) to_xml(options = {})



23
24
25
26
# File 'lib/carrierwave/uploader/serialization.rb', line 23

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