Sha256: 5f97dffbf79029ede272a60c2b9eb8e9b08da63b22e27ab9f541d1129406ebe4

Contents?: true

Size: 418 Bytes

Versions: 3

Compression:

Stored size: 418 Bytes

Contents

module Direct::API::V5
  module Refinements
    # Add camelize method to String and Symbol
    module Camelize
      refine String do
        def camelize
          if self =~ /[A-Z]/
            self
          else
            split('_').map(&:capitalize).join('')
          end
        end
      end

      refine Symbol do
        def camelize
          to_s.camelize.to_sym
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
direct-api-v5-0.1.2 lib/direct/api/v5/refinements/camelize.rb
direct-api-v5-0.1.1 lib/direct/api/v5/refinements/camelize.rb
direct-api-v5-0.1.0 lib/direct/api/v5/refinements/camelize.rb