-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for naming style adapter
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |