Sha256: 761af5f8af32db1193b55527fbf1da724516e05fb5e9e7bec596fb77d0eb4c0c

Contents?: true

Size: 721 Bytes

Versions: 161

Compression:

Stored size: 721 Bytes

Contents

module ActiveResource
  module Formats
    autoload :XmlFormat, 'active_resource/formats/xml_format'
    autoload :JsonFormat, 'active_resource/formats/json_format'

    # Lookup the format class from a mime type reference symbol. Example:
    #
    #   ActiveResource::Formats[:xml]  # => ActiveResource::Formats::XmlFormat
    #   ActiveResource::Formats[:json] # => ActiveResource::Formats::JsonFormat
    def self.[](mime_type_reference)
      ActiveResource::Formats.const_get(ActiveSupport::Inflector.camelize(mime_type_reference.to_s) + "Format")
    end

    def self.remove_root(data)
      if data.is_a?(Hash) && data.keys.size == 1
        data.values.first
      else
        data
      end
    end
  end
end

Version data entries

161 entries across 135 versions & 12 rubygems

Version Path
activeresource-3.2.14 lib/active_resource/formats.rb
activeresource-3.2.14.rc2 lib/active_resource/formats.rb
activeresource-3.2.14.rc1 lib/active_resource/formats.rb
activeresource-4.0.0 lib/active_resource/formats.rb
swipe-rails-0.0.5 vendor/bundle/gems/activeresource-3.2.13/lib/active_resource/formats.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/formats.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/formats.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/formats.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/formats.rb
challah-1.0.0.beta3 vendor/bundle/gems/activeresource-3.2.13/lib/active_resource/formats.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.13/lib/active_resource/formats.rb
challah-1.0.0.beta2 vendor/bundle/gems/activeresource-3.2.13/lib/active_resource/formats.rb
challah-1.0.0.beta vendor/bundle/gems/activeresource-3.2.11/lib/active_resource/formats.rb
challah-1.0.0.beta vendor/bundle/gems/activeresource-3.2.13/lib/active_resource/formats.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.13/lib/active_resource/formats.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.13/lib/active_resource/formats.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.13/lib/active_resource/formats.rb
activeresource-3.2.13 lib/active_resource/formats.rb
activeresource-3.1.12 lib/active_resource/formats.rb
activeresource-3.2.13.rc2 lib/active_resource/formats.rb