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.22.5 lib/active_resource/formats.rb
activeresource-3.2.22.4 lib/active_resource/formats.rb
activeresource-3.2.22.3 lib/active_resource/formats.rb
activeresource-4.1.0 lib/active_resource/formats.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activeresource-4.0.0/lib/active_resource/formats.rb
activeresource-3.2.22.2 lib/active_resource/formats.rb
activeresource-3.2.22.1 lib/active_resource/formats.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activeresource-3.2.12/lib/active_resource/formats.rb
activeresource-3.2.22 lib/active_resource/formats.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activeresource-3.2.12/lib/active_resource/formats.rb
activeresource-3.2.21 lib/active_resource/formats.rb
activeresource-3.2.20 lib/active_resource/formats.rb
activeresource-3.2.19 lib/active_resource/formats.rb
activeresource-3.2.18 lib/active_resource/formats.rb
activeresource-3.2.17 lib/active_resource/formats.rb
activeresource-3.2.16 lib/active_resource/formats.rb
activeresource-3.2.15 lib/active_resource/formats.rb
activeresource-3.2.15.rc3 lib/active_resource/formats.rb
activeresource-3.2.15.rc2 lib/active_resource/formats.rb
activeresource-3.2.15.rc1 lib/active_resource/formats.rb