Sha256: 42d0c4ca98da09a987e1f9229283b905778946c1dbc14bc9cc39a4632a808624

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

module Restfulie
  module Common
    module Converter
      autoload :Values, 'restfulie/common/converter/values'
      autoload :Atom, 'restfulie/common/converter/atom'
      autoload :Json, 'restfulie/common/converter/json'
      autoload :Xml, 'restfulie/common/converter/xml'

      # Returns the default root element name for an item or collection
      def self.root_element_for(obj)
        if obj.kind_of?(Hash) && obj.size==1
          obj.keys.first.to_s
        elsif obj.kind_of?(Array) && !obj.empty?
          root_element_for(obj.first).to_s.underscore.pluralize
        else
          obj.class.to_s.underscore
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restfulie-0.9.3 lib/restfulie/common/converter.rb
restfulie-0.9.1 lib/restfulie/common/converter.rb
restfulie-0.8.1 lib/restfulie/common/converter.rb