Skip to content

ericproulx/olive_branch

 
 

Repository files navigation

OliveBranch

Maintainability Test Coverage Build Status

This gem lets your API users pass in and receive camelCased or dash-cased keys, while your Rails app receives and produces snake_cased ones.

Install

  1. Add this to your Gemfile and then bundle install:

     gem "olive_branch", git: 'https://github.com/ericproulx/olive_branch.git'
    

Use Rails

The middleware will be automatically added through Railtie

Include a X-Key-Inflection header with values of camel, dash, or snake in your JSON API requests.

Configuration

# config/initializers/olive_branch.rb
OliveBranch.configuration do |config|
  config.camelize = # your camelize function ( Default: string.underscore.camelize(:lower))
  config.dasherize = # your dasherize function ( Default: string.dasherize)
  config.content_type_check = # your content type check function ( Default: 'application/json')
  config.default_inflection = # if you don't want to include the header key in every request, you can default an inflection
  config.header_key = # your header key ( Default: HTTP_X_KEY_INFLECTION )
end

OliveBranch is released under the MIT License. See MIT-LICENSE for further details.


Code At Viget

Visit code.viget.com to see more projects from Viget.

About

Handle camel/snake/dash case conversion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%