Sha256: 8a0a66d6680dcbe6798a6dc7644d6745bfa56b87a1491a5780ced6b617809098

Contents?: true

Size: 503 Bytes

Versions: 1

Compression:

Stored size: 503 Bytes

Contents

require 'tokamak/xml'
require 'tokamak/json'
require 'tokamak/atom'
require 'tokamak/values'
require 'tokamak/representation'
require 'tokamak/error'

module Tokamak
  
  # 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokamak-1.0.0.beta2 lib/tokamak.rb