Module: ActiveResource::Formats

### Home Classes Methods

### In Files

- lib/active_resource/formats.rb
- lib/active_resource/formats/json_format.rb
- lib/active_resource/formats/xml_format.rb

### Namespace

- MODULE ActiveResource::Formats::JsonFormat
- MODULE ActiveResource::Formats::XmlFormat

### Methods

- ::[]
- ::remove_root

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- ActiveResource
- ActiveResource::Base
- ActiveResource::Connection
- ActiveResource::CustomMethods
- ActiveResource::CustomMethods::ClassMethods
- ActiveResource::Errors
- ActiveResource::Formats
- ActiveResource::Formats::JsonFormat
- ActiveResource::Formats::XmlFormat
- ActiveResource::HttpMock
- ActiveResource::InvalidRequestError
- ActiveResource::LogSubscriber
- ActiveResource::Observing
- ActiveResource::Railtie
- ActiveResource::Request
- ActiveResource::Response
- ActiveResource::SSLError
- ActiveResource::TimeoutError
- ActiveResource::Validations

No matching classes.

# ActiveResource::Formats

### Public Class Methods

[](mime_type_reference) click to toggle source

Lookup the format class from a mime type reference symbol. Example:

    ActiveResource::Formats[:xml]  # => ActiveResource::Formats::XmlFormat
    ActiveResource::Formats[:json] # => ActiveResource::Formats::JsonFormat

    # File lib/active_resource/formats.rb, line 10
    def self.[](mime_type_reference)
      ActiveResource::Formats.const_get(ActiveSupport::Inflector.camelize(mime_type_reference.to_s) + "Format")
    end

remove_root(data) click to toggle source

    # File lib/active_resource/formats.rb, line 14
    def self.remove_root(data)
      if data.is_a?(Hash) && data.keys.size == 1
        data.values.first
      else
        data
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.