Sha256: 147d9195de07a9b07eef42b3df4e671355c97cd0ea683796701c9a8e1d41d314

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
savon-2.13.1 lib/savon/core_ext/string.rb
savon-2.13.0 lib/savon/core_ext/string.rb