Sha256: 14f7f57dee5503c3b55bedc7aa299a709b82ce9add24bf3385cdbfce94822b86

Contents?: true

Size: 652 Bytes

Versions: 8

Compression:

Stored size: 652 Bytes

Contents

# Used to format keys
module CarrotRpc::Format
  using CarrotRpc::HashExtensions

  # Logic to process the renaming of keys in a hash.
  # @param format [Symbol] :dasherize changes keys that have "_" to "-"
  # @param format [Symbol] :underscore changes keys that have "-" to "_"
  # @param format [Symbol] :skip, will not rename the keys
  # @param data [Hash] data structure to be transformed
  # @return [Hash] the transformed data
  def self.keys(format, data)
    case format
    when :dasherize
      data.rename_keys("_", "-")
    when :underscore
      data.rename_keys("-", "_")
    when :none
      data
    else
      data
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
carrot_rpc-1.2.1 lib/carrot_rpc/format.rb
carrot_rpc-1.2.0 lib/carrot_rpc/format.rb
carrot_rpc-1.1.0 lib/carrot_rpc/format.rb
carrot_rpc-1.0.0 lib/carrot_rpc/format.rb
carrot_rpc-0.8.0 lib/carrot_rpc/format.rb
carrot_rpc-0.7.1 lib/carrot_rpc/format.rb
carrot_rpc-0.7.0 lib/carrot_rpc/format.rb
carrot_rpc-0.6.0 lib/carrot_rpc/format.rb