Sha256: fcfe5069ffb34224291648c47188e91250529451e1404b855ba5518a907cac5a

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

module Sparrow
  module Strategies
    module KeyTransformation
      ##
      # Strategy class for snake_casing keys
      class UnderscoreKey
        ##
        # Create a new UnderscoreKey Strategy
        # Does nothing except returning a plain instance.
        def initialize(*args)
          # no initialization needed
        end

        ##
        # Transforms the given key to snake_case format
        # @param [String] key the key to be transformed
        # @return [String] the snake_cased key
        def transform_key(key)
          key.to_s.underscore
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cp-sparrow-0.0.14 lib/sparrow/strategies/key_transformation/underscore_key.rb