Sha256: b09056451fa3c1875763827d41b127cedfa5b66287f6ba583b8bc6d913d814c7

Contents?: true

Size: 625 Bytes

Versions: 18

Compression:

Stored size: 625 Bytes

Contents

module Twilio
  module REST
    module Utils

      def twilify(something)
        if something.is_a? Hash
          Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten]
        else
          something.to_s.split('_').map do |s|
            [s[0,1].capitalize, s[1..-1]].join
          end.join
        end
      end

      def detwilify(something)
        if something.is_a? Hash
          Hash[*something.to_a.map {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten]
        else
          something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
        end
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
twilio-ruby-3.10.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.10.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.9.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.8.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.7.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.7.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.6.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.5.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.5.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.4.2 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.4.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.4.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.3.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.3.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.2.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.1.1 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.1.0 lib/twilio-ruby/rest/utils.rb
twilio-ruby-3.0.0 lib/twilio-ruby/rest/utils.rb