Skip to content

Commit

Permalink
Add example for naming style adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Aug 22, 2024
1 parent 5ed3a4c commit 9e5b0b9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/naming_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'bundler/setup'
require 'flipper'
require 'flipper/adapters/naming_style'

Flipper.configure do |config|
config.use Flipper::Adapters::NamingStyle, :snake # or :camel, :kebab, :screaming_snake, or a Regexp
end

# This will work because the feature key is in snake_case.
Flipper.enable(:snake_case)

begin
# This will raise an error because the feature key is in CamelCase.
Flipper.enable(:CamelCase)
rescue Flipper::Adapters::NamingStyle::InvalidFormat => e
puts "#{e.class}: #{e.message}"
else
fail "An error should have been raised, but wasn't."
end

0 comments on commit 9e5b0b9

Please sign in to comment.