Module: CarrierWave::Uploader::Serialization
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/carrierwave/uploader/serialization.rb
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
- #serializable_hash(options = nil) ⇒ Object
- #to_json(options = nil) ⇒ Object
- #to_xml(options = {}) ⇒ Object
Instance Method Details
#as_json(options = nil) ⇒ Object
15 16 17 |
# File 'lib/carrierwave/uploader/serialization.rb', line 15 def as_json(=nil) Hash[mounted_as || "uploader", serializable_hash] end |
#serializable_hash(options = nil) ⇒ Object
11 12 13 |
# File 'lib/carrierwave/uploader/serialization.rb', line 11 def serializable_hash( = nil) {"url" => url}.merge Hash[versions.map { |name, version| [name, { "url" => version.url }] }] end |
#to_json(options = nil) ⇒ Object
19 20 21 |
# File 'lib/carrierwave/uploader/serialization.rb', line 19 def to_json(=nil) JSON.generate(as_json) end |
#to_xml(options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/carrierwave/uploader/serialization.rb', line 23 def to_xml(={}) = .merge(:root => mounted_as || "uploader", :type => 'uploader') serializable_hash.to_xml() end |