Sha256: c7e95a591dd9477a19df73920088dcec968faf8bf6796465028ebb66f4039ce8

Contents?: true

Size: 586 Bytes

Versions: 9

Compression:

Stored size: 586 Bytes

Contents

require "savon/soap"

module Savon
  module CoreExt
    module String

      def self.included(base)
        unless "savon".respond_to?(:snakecase)
          base.send(:include, Extension)
        end
      end

      module Extension
        def snakecase
          str = dup
          str.gsub! /::/, '/'
          str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2'
          str.gsub! /([a-z\d])([A-Z])/, '\1_\2'
          str.tr! ".", "_"
          str.tr! "-", "_"
          str.downcase!
          str
        end
      end

    end
  end
end

String.send :include, Savon::CoreExt::String

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
savon-2.2.0 lib/savon/core_ext/string.rb
savon-2.1.0 lib/savon/core_ext/string.rb
savon-2.0.3 lib/savon/core_ext/string.rb
savon-2.0.2 lib/savon/core_ext/string.rb
savon-2.0.1 lib/savon/core_ext/string.rb
savon-2.0.0 lib/savon/core_ext/string.rb
savon-1.2.0 lib/savon/core_ext/string.rb
savon-1.1.0 lib/savon/core_ext/string.rb
savon-1.0.0 lib/savon/core_ext/string.rb